home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / web / fweb / faq / texinfo.tex (.txt) < prev   
LaTeX Document  |  1993-05-18  |  124KB  |  3,023 lines

  1. %% TeX macros to handle texinfo files
  2. %   Copyright (C) 1985, 86, 88, 90, 91, 92 Free Software Foundation, Inc.
  3. %This texinfo.tex file is free software; you can redistribute it and/or
  4. %modify it under the terms of the GNU General Public License as
  5. %published by the Free Software Foundation; either version 2, or (at
  6. %your option) any later version.
  7. %This texinfo.tex file is distributed in the hope that it will be
  8. %useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  9. %of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  10. %General Public License for more details.
  11. %You should have received a copy of the GNU General Public License
  12. %along with this texinfo.tex file; see the file COPYING.  If not, write
  13. %to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
  14. %USA.
  15. %In other words, you are welcome to use, share and improve this program.
  16. %You are forbidden to forbid anyone else to use, share and improve
  17. %what you give them.   Help stamp out software-hoarding!
  18. \def\texinfoversion{2.90}
  19. \message{Loading texinfo package [Version \texinfoversion]:}
  20. \message{}
  21. % Print the version number if in a .fmt file.
  22. \everyjob{\message{[Texinfo version \texinfoversion]}\message{}}
  23. % Save some parts of plain tex whose names we will redefine.
  24. \let\ptexlbrace=\{
  25. \let\ptexrbrace=\}
  26. \let\ptexdots=\dots
  27. \let\ptexdot=\.
  28. \let\ptexstar=\*
  29. \let\ptexend=\end
  30. \let\ptexbullet=\bullet
  31. \let\ptexb=\b
  32. \let\ptexc=\c
  33. \let\ptexi=\i
  34. \let\ptext=\t
  35. \let\ptexl=\l
  36. \let\ptexL=\L
  37. \def\tie{\penalty 10000\ }     % Save plain tex definition of ~.
  38. \message{Basics,}
  39. \chardef\other=12
  40. % If this character appears in an error message or help string, it
  41. % starts a new line in the output.
  42. \newlinechar = `^^J
  43. % Ignore a token.
  44. \def\gobble#1{}
  45. \hyphenation{ap-pen-dix}
  46. \hyphenation{mini-buf-fer mini-buf-fers}
  47. \hyphenation{eshell}
  48. % Margin to add to right of even pages, to left of odd pages.
  49. \newdimen \bindingoffset  \bindingoffset=0pt
  50. \newdimen \normaloffset   \normaloffset=\hoffset
  51. \newdimen\pagewidth \newdimen\pageheight
  52. \pagewidth=\hsize \pageheight=\vsize
  53. % Sometimes it is convenient to have everything in the transcript file
  54. % and nothing on the terminal.  We don't just call \tracingall here,
  55. % since that produces some useless output on the terminal.
  56. \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
  57. \def\loggingall{\tracingcommands2 \tracingstats2 
  58.    \tracingpages1 \tracingoutput1 \tracinglostchars1 
  59.    \tracingmacros2 \tracingparagraphs1 \tracingrestores1 
  60.    \showboxbreadth\maxdimen\showboxdepth\maxdimen
  61. %---------------------Begin change-----------------------
  62. %%%% For @cropmarks command.
  63. % Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986
  64. \newdimen\cornerlong \newdimen\cornerthick
  65. \newdimen \topandbottommargin
  66. \newdimen \outerhsize \newdimen \outervsize
  67. \cornerlong=1pc\cornerthick=.3pt    % These set size of cropmarks
  68. \outerhsize=7in
  69. %\outervsize=9.5in
  70. % Alternative @smallbook page size is 9.25in
  71. \outervsize=9.25in
  72. \topandbottommargin=.75in
  73. %---------------------End change-----------------------
  74. % \onepageout takes a vbox as an argument.  Note that \pagecontents
  75. % does insertions itself, but you have to call it yourself.
  76. \chardef\PAGE=255  \output={\onepageout{\pagecontents\PAGE}}
  77. \def\onepageout#1{\hoffset=\normaloffset
  78. \ifodd\pageno  \advance\hoffset by \bindingoffset
  79. \else \advance\hoffset by -\bindingoffset\fi
  80. {\escapechar=`\\\relax % makes sure backslash is used in output files.
  81. \shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}%
  82. {\let\hsize=\pagewidth \makefootline}}}%
  83. \advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  84. %%%% For @cropmarks command %%%%
  85. % Here is a modification of the main output routine for Near East Publications
  86. % This provides right-angle cropmarks at all four corners.
  87. % The contents of the page are centerlined into the cropmarks,
  88. % and any desired binding offset is added as an \hskip on either
  89. % site of the centerlined box.  (P. A. MacKay, 12 November, 1986)
  90. \def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up
  91. {\escapechar=`\\\relax % makes sure backslash is used in output files.
  92.          \shipout
  93.          \vbox to \outervsize{\hsize=\outerhsize
  94.                  \vbox{\line{\ewtop\hfill\ewtop}}
  95.                  \nointerlineskip
  96.                  \line{\vbox{\moveleft\cornerthick\nstop}
  97.                        \hfill
  98.                        \vbox{\moveright\cornerthick\nstop}}
  99.                  \vskip \topandbottommargin
  100.                  \centerline{\ifodd\pageno\hskip\bindingoffset\fi
  101.             \vbox{
  102.             {\let\hsize=\pagewidth \makeheadline}
  103.             \pagebody{#1}
  104.             {\let\hsize=\pagewidth \makefootline}}
  105.             \ifodd\pageno\else\hskip\bindingoffset\fi}
  106.          \vskip \topandbottommargin plus1fill minus1fill
  107.                  \boxmaxdepth\cornerthick
  108.                  \line{\vbox{\moveleft\cornerthick\nsbot}
  109.                        \hfill
  110.                        \vbox{\moveright\cornerthick\nsbot}}
  111.                  \nointerlineskip
  112.                  \vbox{\line{\ewbot\hfill\ewbot}}
  113.   \advancepageno 
  114.   \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  115. % Do @cropmarks to get crop marks
  116. \def\cropmarks{\let\onepageout=\croppageout }
  117. \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
  118. {\catcode`\@ =11
  119. \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
  120. \dimen@=\dp#1 \unvbox#1
  121. \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
  122. \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
  123. % Here are the rules for the cropmarks.  Note that they are
  124. % offset so that the space between them is truly \outerhsize or \outervsize
  125. % (P. A. MacKay, 12 November, 1986)
  126. \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
  127. \def\nstop{\vbox
  128.   {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
  129. \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
  130. \def\nsbot{\vbox
  131.   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
  132. % Parse an argument, then pass it to #1.  The argument is the rest of
  133. % the input line (except we remove a trailing comment).  #1 should be a
  134. % macro which expects an ordinary undelimited TeX argument.
  135. \def\parsearg#1{%
  136.   \let\next = #1%
  137.   \begingroup
  138.     \obeylines
  139.     \futurelet\temp\parseargx
  140. % If the next token is an obeyed space (from an @example environment or
  141. % the like), remove it and recurse.  Otherwise, we're done.
  142. \def\parseargx{%
  143.   \ifx\obeyedspace\temp
  144.     \expandafter\parseargdiscardspace
  145.   \else
  146.     \expandafter\parseargline
  147.   \fi
  148. % Remove a single space (as the delimiter token to the macro call).
  149. {\obeyspaces %
  150.  \gdef\parseargdiscardspace {\futurelet\temp\parseargx}}
  151. \def\obeyedspace{\ }
  152. {\obeylines %
  153.   \gdef\parseargline#1^^M{%
  154.     \endgroup % End of the group started in \parsearg.
  155.     %
  156.     % First remove any @c comment, then any @comment.
  157.     % Result of each macro is put in \toks0.
  158.     \argremovec #1\c\relax %
  159.     \expandafter\argremovecomment \the\toks0 \comment\relax %
  160.     %
  161.     % Call the caller's macro, saved as \next in \parsearg.
  162.     \expandafter\next\expandafter{\the\toks0}%
  163. % Since all \c{,omment} does is throw away the argument, we can let TeX
  164. % do that for us.  The \relax here is matched by the \relax in the call
  165. % in \parseargline; it could be more or less anything, its purpose is
  166. % just to delimit the argument to the \c.
  167. \def\argremovec#1\c#2\relax{\toks0 = {#1}}
  168. \def\argremovecomment#1\comment#2\relax{\toks0 = {#1}}
  169. % \argremovec{,omment} might leave us with trailing spaces, though; e.g.,
  170. %    @end itemize  @c foo
  171. % will have two active spaces as part of the argument with the
  172. % `itemize'.  Here we remove all active spaces from #1, and assign the
  173. % result to \toks0.
  174. % This loses if there are any *other* active characters besides spaces
  175. % in the argument -- _ ^ +, for example -- since they get expanded.
  176. % Fortunately, Texinfo does not define any such commands.  (If it ever
  177. % does, the catcode of the characters in questionwill have to be changed
  178. % here.)  But this means we cannot call \removeactivespaces as part of
  179. % \argremovec{,omment}, since @c uses \parsearg, and thus the argument
  180. % that \parsearg gets might well have any character at all in it.
  181. \def\removeactivespaces#1{%
  182.   \begingroup
  183.     \ignoreactivespaces
  184.     \edef\temp{#1}%
  185.     \global\toks0 = \expandafter{\temp}%
  186.   \endgroup
  187. % Change the active space to expand to nothing.
  188. \begingroup
  189.   \obeyspaces
  190.   \gdef\ignoreactivespaces{\obeyspaces\let =\empty}
  191. \endgroup
  192. \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
  193. %% These are used to keep @begin/@end levels from running away
  194. %% Call \inENV within environments (after a \begingroup)
  195. \newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
  196. \def\ENVcheck{%
  197. \ifENV\errmessage{Still within an environment.  Type Return to continue.}
  198. \endgroup\fi} % This is not perfect, but it should reduce lossage
  199. % @begin foo  is the same as @foo, for now.
  200. \newhelp\EMsimple{Type <Return> to continue.}
  201. \outer\def\begin{\parsearg\beginxxx}
  202. \def\beginxxx #1{%
  203. \expandafter\ifx\csname #1\endcsname\relax
  204. {\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
  205. \csname #1\endcsname\fi}
  206. % @end foo executes the definition of \Efoo.
  207. \def\end{\parsearg\endxxx}
  208. \def\endxxx #1{%
  209.   \removeactivespaces{#1}%
  210.   \edef\endthing{\the\toks0}%
  211.   \expandafter\ifx\csname E\endthing\endcsname\relax
  212.     \expandafter\ifx\csname \endthing\endcsname\relax
  213.       % There's no \foo, i.e., no ``environment'' foo.
  214.       \errhelp = \EMsimple
  215.       \errmessage{Undefined command `@end \endthing'}%
  216.     \else
  217.       \unmatchedenderror\endthing
  218.     \fi
  219.   \else
  220.     % Everything's ok; the right environment has been started.
  221.     \csname E\endthing\endcsname
  222.   \fi
  223. % There is an environment #1, but it hasn't been started.  Give an error.
  224. \def\unmatchedenderror#1{%
  225.   \errhelp = \EMsimple
  226.   \errmessage{This `@end #1' doesn't have a matching `@#1'}%
  227. % Define the control sequence \E#1 to give an unmatched @end error.
  228. \def\defineunmatchedend#1{%
  229.   \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}%
  230. % Single-spacing is done by various environments.
  231. \newskip\singlespaceskip \singlespaceskip = \baselineskip
  232. \def\singlespace{%
  233. {\advance \baselineskip by -\singlespaceskip
  234. \kern \baselineskip}%
  235. \baselineskip=\singlespaceskip
  236. %% Simple single-character @ commands
  237. % @@ prints an @
  238. % Kludge this until the fonts are right (grr).
  239. \def\@{{\tt \char '100}}
  240. % This is turned off because it was never documented
  241. % and you can use @w{...} around a quote to suppress ligatures.
  242. %% Define @` and @' to be the same as ` and '
  243. %% but suppressing ligatures.
  244. %\def\`{{`}}
  245. %\def\'{{'}}
  246. % Used to generate quoted braces.
  247. \def\mylbrace {{\tt \char '173}}
  248. \def\myrbrace {{\tt \char '175}}
  249. \let\{=\mylbrace
  250. \let\}=\myrbrace
  251. % @: forces normal size whitespace following.
  252. \def\:{\spacefactor=1000 }
  253. % @* forces a line break.
  254. \def\*{\hfil\break\hbox{}\ignorespaces}
  255. % @. is an end-of-sentence period.
  256. \def\.{.\spacefactor=3000 }
  257. % @w prevents a word break.  Without the \leavevmode, @w at the
  258. % beginning of a paragraph, when TeX is still in vertical mode, would
  259. % produce a whole line of output instead of starting the paragraph.
  260. \def\w#1{\leavevmode\hbox{#1}}
  261. % @group ... @end group forces ... to be all on one page, by enclosing
  262. % it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
  263. % to keep its height that of a normal line.  According to the rules for
  264. % \topskip (p.114 of the TeXbook), the glue inserted is
  265. % max (\topskip - \ht (first item), 0).  If that height is large,
  266. % therefore, no glue is inserted, and the space between the headline and
  267. % the text is small, which looks bad.
  268. \def\group{\begingroup
  269.   \ifnum\catcode13=\active \else
  270.     \errhelp = \groupinvalidhelp
  271.     \errmessage{@group invalid in context where filling is enabled}%
  272.   \fi
  273.   % The \vtop we start below produces a box with large depth; thus, TeX
  274.   % puts \baselineskip glue before it, and (when the next line of text
  275.   % is done) \lineskip glue after it.  (See p.82 of the TeXbook.)  But
  276.   % the next line of text also gets us \parskip glue.  Final result:
  277.   % space below is slightly more than space above.
  278.   \def\Egroup{%
  279.     \egroup           % End the \vtop.
  280.     \endgroup         % End the \group.
  281.   \vtop\bgroup
  282.     % We do @comment here in case we are called inside an environment,
  283.     % such as @example, where each end-of-line in the input causes an
  284.     % end-of-line in the output.  We don't want the end-of-line after
  285.     % the `@group' to put extra space in the output.  Since @group
  286.     % should appear on a line by itself (according to the Texinfo
  287.     % manual), we don't worry about eating any user text.
  288.     \comment
  289. % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
  290. % message, so this ends up printing `@group can only ...'.
  291. \newhelp\groupinvalidhelp{%
  292. group can only be used in environments such as @example,^^J%
  293. where each line of input produces a line of output.}
  294. % @need space-in-mils
  295. % forces a page break if there is not space-in-mils remaining.
  296. \newdimen\mil  \mil=0.001in
  297. \def\need{\parsearg\needx}
  298. % Old definition--didn't work.
  299. %\def\needx #1{\par %
  300. %% This method tries to make TeX break the page naturally
  301. %% if the depth of the box does not fit.
  302. %{\baselineskip=0pt%
  303. %\vtop to #1\mil{\vfil}\kern -#1\mil\penalty 10000
  304. %\prevdepth=-1000pt
  305. \def\needx#1{%
  306.   % Go into vertical mode, so we don't make a big box in the middle of a
  307.   % paragraph.
  308.   \par
  309.   % Don't add any leading before our big empty box, but allow a page
  310.   % break, since the best break might be right here.
  311.   \allowbreak
  312.   \nointerlineskip
  313.   \vtop to #1\mil{\vfil}%
  314.   % TeX does not even consider page breaks if a penalty added to the
  315.   % main vertical list is 10000 or more.  But in order to see if the
  316.   % empty box we just added fits on the page, we must make it consider
  317.   % page breaks.  On the other hand, we don't want to actually break the
  318.   % page after the empty box.  So we use a penalty of 9999.
  319.   % There is an extremely small chance that TeX will actually break the
  320.   % page at this \penalty, if there are no other feasible breakpoints in
  321.   % sight.  (If the user is using lots of big @group commands, which
  322.   % almost-but-not-quite fill up a page, TeX will have a hard time doing
  323.   % good page breaking, for example.)  However, I could not construct an
  324.   % example where a page broke at this \penalty; if it happens in a real
  325.   % document, then we can reconsider our strategy.
  326.   \penalty9999
  327.   % Back up by the size of the box, whether we did a page break or not.
  328.   \kern -#1\mil
  329.   % Do not allow a page break right after this kern.
  330.   \nobreak
  331. % @br   forces paragraph break
  332. \let\br = \par
  333. % @dots{}  output some dots
  334. \def\dots{$\ldots$}
  335. % @page    forces the start of a new page
  336. \def\page{\par\vfill\supereject}
  337. % @exdent text....
  338. % outputs text on separate line in roman font, starting at standard page margin
  339. % This records the amount of indent in the innermost environment.
  340. % That's how much \exdent should take out.
  341. \newskip\exdentamount
  342. % This defn is used inside fill environments such as @defun.
  343. \def\exdent{\parsearg\exdentyyy}
  344. \def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}}
  345. % This defn is used inside nofill environments such as @example.
  346. \def\nofillexdent{\parsearg\nofillexdentyyy}
  347. \def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount
  348. \leftline{\hskip\leftskip{\rm#1}}}}
  349. %\hbox{{\rm#1}}\hfil\break}}
  350. % @include file    insert text of that file as input.
  351. \def\include{\parsearg\includezzz}
  352. \def\includezzz #1{{\def\thisfile{#1}\input #1
  353. \def\thisfile{}
  354. % @center line   outputs that line, centered
  355. \def\center{\parsearg\centerzzz}
  356. \def\centerzzz #1{{\advance\hsize by -\leftskip
  357. \advance\hsize by -\rightskip
  358. \centerline{#1}}}
  359. % @sp n   outputs n lines of vertical space
  360. \def\sp{\parsearg\spxxx}
  361. \def\spxxx #1{\par \vskip #1\baselineskip}
  362. % @comment ...line which is ignored...
  363. % @c is the same as @comment
  364. % @ignore ... @end ignore  is another way to write a comment
  365. \def\comment{\catcode 64=\other \catcode 123=\other \catcode 125=\other%
  366. \parsearg \commentxxx}
  367. \def\commentxxx #1{\catcode 64=0 \catcode 123=1 \catcode 125=2 }
  368. \let\c=\comment
  369. % Prevent errors for section commands.
  370. % Used in @ignore and in failing conditionals.
  371. \def\ignoresections{%
  372. \let\chapter=\relax
  373. \let\unnumbered=\relax
  374. \let\top=\relax
  375. \let\unnumberedsec=\relax
  376. \let\unnumberedsection=\relax
  377. \let\unnumberedsubsec=\relax
  378. \let\unnumberedsubsection=\relax
  379. \let\unnumberedsubsubsec=\relax
  380. \let\unnumberedsubsubsection=\relax
  381. \let\section=\relax
  382. \let\subsec=\relax
  383. \let\subsubsec=\relax
  384. \let\subsection=\relax
  385. \let\subsubsection=\relax
  386. \let\appendix=\relax
  387. \let\appendixsec=\relax
  388. \let\appendixsection=\relax
  389. \let\appendixsubsec=\relax
  390. \let\appendixsubsection=\relax
  391. \let\appendixsubsubsec=\relax
  392. \let\appendixsubsubsection=\relax
  393. \let\contents=\relax
  394. \let\smallbook=\relax
  395. \let\titlepage=\relax
  396. % Used in nested conditionals, where we have to parse the Texinfo source
  397. % and so want to turn off most commands, in case they are used
  398. % incorrectly.  
  399. \def\ignoremorecommands{%
  400.   \let\defcv = \relax
  401.   \let\deffn = \relax
  402.   \let\deffnx = \relax
  403.   \let\defindex = \relax
  404.   \let\defivar = \relax
  405.   \let\defmac = \relax
  406.   \let\defmethod = \relax
  407.   \let\defop = \relax
  408.   \let\defopt = \relax
  409.   \let\defspec = \relax
  410.   \let\deftp = \relax
  411.   \let\deftypefn = \relax
  412.   \let\deftypefun = \relax
  413.   \let\deftypevar = \relax
  414.   \let\deftypevr = \relax
  415.   \let\defun = \relax
  416.   \let\defvar = \relax
  417.   \let\defvr = \relax
  418. % Ignore @ignore ... @end ignore.
  419. \def\ignore{\doignore{ignore}}
  420. % Also ignore @ifinfo, @menu, and @direntry text.
  421. \def\ifinfo{\doignore{ifinfo}}
  422. \def\menu{\doignore{menu}}
  423. \def\direntry{\doignore{direntry}}
  424. % Ignore text until a line `@end #1'.
  425. \def\doignore#1{\begingroup
  426.   % Don't complain about control sequences we have declared \outer.
  427.   \ignoresections
  428.   % Define a command to swallow text until we reach `@end #1'.
  429.   \long\def\doignoretext##1\end #1{\enddoignore}%
  430.   % Make sure that spaces turn into tokens that match what \doignoretext wants.
  431.   \catcode32 = 10
  432.   % And now expand that command.
  433.   \doignoretext
  434. % What we do to finish off ignored text.
  435. \def\enddoignore{\endgroup\ignorespaces}%
  436. % Ignore text, except that we keep track of conditional commands for
  437. % purposes of nesting, up to an `@end #1' command.
  438. \def\nestedignore#1{%
  439.   % We must actually expand the ignored text to look for the @end
  440.   % command, so that nested ignore constructs work.  Thus, we put the
  441.   % text into a \vbox and then do nothing with the result.  To minimize
  442.   % the change of memory overflow, we follow the approach outlined on
  443.   % page 401 of the TeXbook: make the current font be a dummy font.
  444.   \setbox0 = \vbox\bgroup
  445.     % Don't complain about control sequences we have declared \outer.
  446.     \ignoresections
  447.     %
  448.     % Define `@end #1' to end the box, which will in turn undefine the
  449.     % @end command again.
  450.     \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}%
  451.     %
  452.     % We are going to be parsing Texinfo commands.  Most cause no
  453.     % trouble when they are used incorrectly, but some commands do
  454.     % complicated argument parsing or otherwise get confused, so we
  455.     % undefine them.
  456.     %
  457.     % We can't do anything about stray @-signs, unfortunately;
  458.     % they'll produce `undefined control sequence' errors.
  459.     \ignoremorecommands
  460.     % 
  461.     % Set the current font to be \nullfont, a TeX primitive, and define
  462.     % all the font commands to also use \nullfont.  We don't use
  463.     % dummy.tfm, as suggested in the TeXbook, because not all sites
  464.     % might have that installed.  Therefore, math mode will still
  465.     % produce output, but that should be an extremely small amount of
  466.     % stuff compared to the main input.
  467.     \nullfont
  468.     \let\tenrm = \nullfont  \let\tenit = \nullfont  \let\tensl = \nullfont
  469.     \let\tenbf = \nullfont  \let\tentt = \nullfont  \let\smallcaps = \nullfont
  470.     \let\tensf = \nullfont
  471.     %
  472.     % Don't complain when characters are missing from the fonts.
  473.     \tracinglostchars = 0
  474.     %
  475.     % Don't bother to do space factor calculations.
  476.     \frenchspacing
  477.     %
  478.     % Don't report underfull hboxes.
  479.     \hbadness = 10000
  480.     %
  481.     % Do minimal line-breaking.
  482.     \pretolerance = 10000
  483. % @set VAR sets the variable VAR to an empty value.
  484. % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
  485. % Since we want to separate VAR from REST-OF-LINE (which might be
  486. % empty), we can't just use \parsearg; we have to insert a space of our
  487. % own to delimit the rest of the line, and then take it out again if we
  488. % didn't need it.
  489. \def\set{\parsearg\setxxx}
  490. \def\setxxx#1{\setyyy#1 \endsetyyy}
  491. \def\setyyy#1 #2\endsetyyy{%
  492.   \def\temp{#2}%
  493.   \ifx\temp\empty \expandafter\let\csname SET#1\endcsname = \empty
  494.   \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted.
  495.   \fi
  496. \def\setzzz#1#2 \endsetzzz{\expandafter\edef\csname SET#1\endcsname{#2}}
  497. % @clear VAR clears (i.e., unsets) the variable VAR.
  498. \def\clear{\parsearg\clearxxx}
  499. \def\clearxxx#1{\expandafter\let\csname SET#1\endcsname=\relax}
  500. % @value{foo} gets the text saved in variable foo.
  501. \def\value#1{\expandafter
  502.         \ifx\csname SET#1\endcsname\relax
  503.             {\{No value for ``#1''\}}
  504.         \else \csname SET#1\endcsname \fi}
  505. % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
  506. % with @set.
  507. \def\ifset{\parsearg\ifsetxxx}
  508. \def\ifsetxxx #1{%
  509.   \expandafter\ifx\csname SET#1\endcsname\relax
  510.     \expandafter\ifsetfail
  511.   \else
  512.     \expandafter\ifsetsucceed
  513.   \fi
  514. \def\ifsetsucceed{\conditionalsucceed{ifset}}
  515. \def\ifsetfail{\nestedignore{ifset}}
  516. \defineunmatchedend{ifset}
  517. % @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been
  518. % defined with @set, or has been undefined with @clear.
  519. \def\ifclear{\parsearg\ifclearxxx}
  520. \def\ifclearxxx #1{%
  521.   \expandafter\ifx\csname SET#1\endcsname\relax
  522.     \expandafter\ifclearsucceed
  523.   \else
  524.     \expandafter\ifclearfail
  525.   \fi
  526. \def\ifclearsucceed{\conditionalsucceed{ifclear}}
  527. \def\ifclearfail{\nestedignore{ifclear}}
  528. \defineunmatchedend{ifclear}
  529. % @iftex always succeeds; we read the text following, through @end
  530. % iftex).  But `@end iftex' should be valid only after an @iftex.
  531. \def\iftex{\conditionalsucceed{iftex}}
  532. \defineunmatchedend{iftex}
  533. % We can't just want to start a group at @iftex (for example) and end it
  534. % at @end iftex, since then @set commands inside the conditional have no
  535. % effect (they'd get reverted at the end of the group).  So we must
  536. % define \Eiftex to redefine itself to be its previous value.  (We can't
  537. % just define it to fail again with an ``unmatched end'' error, since
  538. % the @ifset might be nested.)
  539. \def\conditionalsucceed#1{%
  540.   \edef\temp{%
  541.     % Remember the current value of \E#1.
  542.     \let\nece{prevE#1} = \nece{E#1}%
  543.     %
  544.     % At the `@end #1', redefine \E#1 to be its previous value.
  545.     \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}%
  546.   \temp
  547. % We need to expand lots of \csname's, but we don't want to expand the
  548. % control sequences after we've constructed them.
  549. \def\nece#1{\expandafter\noexpand\csname#1\endcsname}
  550. % @asis just yields its argument.  Used with @table, for example.
  551. \def\asis#1{#1}
  552. % @math means output in math mode.
  553. % We don't use $'s directly in the definition of \math because control
  554. % sequences like \math are expanded when the toc file is written.  Then,
  555. % we read the toc file back, the $'s will be normal characters (as they
  556. % should be, according to the definition of Texinfo).  So we must use a
  557. % control sequence to switch into and out of math mode.
  558. % This isn't quite enough for @math to work properly in indices, but it
  559. % seems unlikely it will ever be needed there.
  560. \let\implicitmath = $
  561. \def\math#1{\implicitmath #1\implicitmath}
  562. % @bullet and @minus need the same treatment as @math, just above.
  563. \def\bullet{\implicitmath\ptexbullet\implicitmath}
  564. \def\minus{\implicitmath-\implicitmath}
  565. \def\node{\ENVcheck\parsearg\nodezzz}
  566. \def\nodezzz#1{\nodexxx [#1,]}
  567. \def\nodexxx[#1,#2]{\gdef\lastnode{#1}}
  568. \let\lastnode=\relax
  569. \def\donoderef{\ifx\lastnode\relax\else
  570. \expandafter\expandafter\expandafter\setref{\lastnode}\fi
  571. \let\lastnode=\relax}
  572. \def\unnumbnoderef{\ifx\lastnode\relax\else
  573. \expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi
  574. \let\lastnode=\relax}
  575. \def\appendixnoderef{\ifx\lastnode\relax\else
  576. \expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi
  577. \let\lastnode=\relax}
  578. \let\refill=\relax
  579. % @setfilename is done at the beginning of every texinfo file.
  580. % So open here the files we need to have open while reading the input.
  581. % This makes it possible to make a .fmt file for texinfo.
  582. \def\setfilename{%
  583.    \readauxfile
  584.    \opencontents
  585.    \openindices
  586.    \fixbackslash  % Turn off hack to swallow `\input texinfo'.
  587.    \global\let\setfilename=\comment % Ignore extra @setfilename cmds.
  588.    \comment % Ignore the actual filename.
  589. \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
  590. \def\inforef #1{\inforefzzz #1,,,,**}
  591. \def\inforefzzz #1,#2,#3,#4**{See Info file \file{\ignorespaces #3{}},
  592.   node \samp{\ignorespaces#1{}}}
  593. \message{fonts,}
  594. % Font-change commands.
  595. % Texinfo supports the sans serif font style, which plain TeX does not.
  596. % So we set up a \sf analogous to plain's \rm, etc.
  597. \newfam\sffam
  598. \def\sf{\fam=\sffam \tensf}
  599. \let\li = \sf % Sometimes we call it \li, not \sf.
  600. %% Try out Computer Modern fonts at \magstephalf
  601. \let\mainmagstep=\magstephalf
  602. \ifx\bigger\relax
  603. \let\mainmagstep=\magstep1
  604. \font\textrm=cmr12
  605. \font\texttt=cmtt12
  606. \else
  607. \font\textrm=cmr10 scaled \mainmagstep
  608. \font\texttt=cmtt10 scaled \mainmagstep
  609. % Instead of cmb10, you many want to use cmbx10.
  610. % cmbx10 is a prettier font on its own, but cmb10
  611. % looks better when embedded in a line with cmr10.
  612. \font\textbf=cmb10 scaled \mainmagstep 
  613. \font\textit=cmti10 scaled \mainmagstep
  614. \font\textsl=cmsl10 scaled \mainmagstep
  615. \font\textsf=cmss10 scaled \mainmagstep
  616. \font\textsc=cmcsc10 scaled \mainmagstep
  617. \font\texti=cmmi10 scaled \mainmagstep
  618. \font\textsy=cmsy10 scaled \mainmagstep
  619. % A few fonts for @defun, etc.
  620. \font\defbf=cmbx10 scaled \magstep1 %was 1314
  621. \font\deftt=cmtt10 scaled \magstep1
  622. \def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf}
  623. % Fonts for indices and small examples.
  624. % We actually use the slanted font rather than the italic, 
  625. % because texinfo normally uses the slanted fonts for that.
  626. % Do not make many font distinctions in general in the index, since they
  627. % aren't very useful.
  628. \font\ninett=cmtt9
  629. \font\indrm=cmr9
  630. \font\indit=cmsl9
  631. \let\indsl=\indit
  632. \let\indtt=\ninett
  633. \let\indsf=\indrm
  634. \let\indbf=\indrm
  635. \let\indsc=\indrm
  636. \font\indi=cmmi9
  637. \font\indsy=cmsy9
  638. % Fonts for headings
  639. \font\chaprm=cmbx12 scaled \magstep2
  640. \font\chapit=cmti12 scaled \magstep2
  641. \font\chapsl=cmsl12 scaled \magstep2
  642. \font\chaptt=cmtt12 scaled \magstep2
  643. \font\chapsf=cmss12 scaled \magstep2
  644. \let\chapbf=\chaprm
  645. \font\chapsc=cmcsc10 scaled\magstep3
  646. \font\chapi=cmmi12 scaled \magstep2
  647. \font\chapsy=cmsy10 scaled \magstep3
  648. \font\secrm=cmbx12 scaled \magstep1
  649. \font\secit=cmti12 scaled \magstep1
  650. \font\secsl=cmsl12 scaled \magstep1
  651. \font\sectt=cmtt12 scaled \magstep1
  652. \font\secsf=cmss12 scaled \magstep1
  653. \font\secbf=cmbx12 scaled \magstep1
  654. \font\secsc=cmcsc10 scaled\magstep2
  655. \font\seci=cmmi12 scaled \magstep1
  656. \font\secsy=cmsy10 scaled \magstep2
  657. % \font\ssecrm=cmbx10 scaled \magstep1    % This size an font looked bad.
  658. % \font\ssecit=cmti10 scaled \magstep1    % The letters were too crowded.
  659. % \font\ssecsl=cmsl10 scaled \magstep1
  660. % \font\ssectt=cmtt10 scaled \magstep1
  661. % \font\ssecsf=cmss10 scaled \magstep1
  662. %\font\ssecrm=cmb10 scaled 1315    % Note the use of cmb rather than cmbx.
  663. %\font\ssecit=cmti10 scaled 1315    % Also, the size is a little larger than
  664. %\font\ssecsl=cmsl10 scaled 1315    % being scaled magstep1.
  665. %\font\ssectt=cmtt10 scaled 1315
  666. %\font\ssecsf=cmss10 scaled 1315
  667. %\let\ssecbf=\ssecrm
  668. \font\ssecrm=cmbx12 scaled \magstephalf
  669. \font\ssecit=cmti12 scaled \magstephalf
  670. \font\ssecsl=cmsl12 scaled \magstephalf
  671. \font\ssectt=cmtt12 scaled \magstephalf
  672. \font\ssecsf=cmss12 scaled \magstephalf
  673. \font\ssecbf=cmbx12 scaled \magstephalf
  674. \font\ssecsc=cmcsc10 scaled \magstep1 
  675. \font\sseci=cmmi12 scaled \magstephalf
  676. \font\ssecsy=cmsy10 scaled \magstep1
  677. % The smallcaps and symbol fonts should actually be scaled \magstep1.5,
  678. % but that is not a standard magnification.
  679. % Fonts for title page:
  680. \font\titlerm = cmbx12 scaled \magstep3
  681. \let\authorrm = \secrm
  682. % In order for the font changes to affect most math symbols and letters,
  683. % we have to define the \textfont of the standard families.  Since
  684. % texinfo doesn't allow for producing subscripts and superscripts, we
  685. % don't bother to reset \scriptfont and \scriptscriptfont (which would
  686. % also require loading a lot more fonts).
  687. \def\resetmathfonts{%
  688.   \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy
  689.   \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf
  690.   \textfont\ttfam = \tentt \textfont\sffam = \tensf
  691. % The font-changing commands redefine the meanings of \tenSTYLE, instead
  692. % of just \STYLE.  We do this so that font changes will continue to work
  693. % in math mode, where it is the current \fam that is relevant in most
  694. % cases, not the current.  Plain TeX does, for example,
  695. % \def\bf{\fam=\bffam \tenbf}  By redefining \tenbf, we obviate the need
  696. % to redefine \bf itself.  
  697. \def\textfonts{%
  698.   \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
  699.   \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
  700.   \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy
  701.   \resetmathfonts}
  702. \def\chapfonts{%
  703.   \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl 
  704.   \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
  705.   \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy
  706.   \resetmathfonts}
  707. \def\secfonts{%
  708.   \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
  709.   \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
  710.   \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy
  711.   \resetmathfonts}
  712. \def\subsecfonts{%
  713.   \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
  714.   \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
  715.   \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy
  716.   \resetmathfonts}
  717. \def\indexfonts{%
  718.   \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl
  719.   \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc
  720.   \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy
  721.   \resetmathfonts}
  722. % Set up the default fonts, so we can use them for creating boxes.
  723. \textfonts
  724. % Count depth in font-changes, for error checks
  725. \newcount\fontdepth \fontdepth=0
  726. % Fonts for short table of contents.
  727. \font\shortcontrm=cmr12
  728. \font\shortcontbf=cmbx12
  729. \font\shortcontsl=cmsl12
  730. %% Add scribe-like font environments, plus @l for inline lisp (usually sans
  731. %% serif) and @ii for TeX italic
  732. % \smartitalic{ARG} outputs arg in italics, followed by an italic correction
  733. % unless the following character is such as not to need one.
  734. \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi}
  735. \def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx}
  736. \let\i=\smartitalic
  737. \let\var=\smartitalic
  738. \let\dfn=\smartitalic
  739. \let\emph=\smartitalic
  740. \let\cite=\smartitalic
  741. \def\b#1{{\bf #1}}
  742. \let\strong=\b
  743. % ??? Setting \exhyphenpenalty doesn't really do anything;
  744. % it only has effect at the end of a paragraph.
  745. % Is there some other way to do the job?
  746. % The problem occurs in \tclose and \key also.
  747. \def\t#1{{\tt \exhyphenpenalty=10000\rawbackslash \frenchspacing #1}\null}
  748. \let\ttfont = \t
  749. %\def\samp #1{`{\tt \rawbackslash \frenchspacing #1}'\null}
  750. \def\samp #1{`\tclose{#1}'\null}
  751. \def\key #1{{\tt \exhyphenpenalty=10000\uppercase{#1}}\null}
  752. \def\ctrl #1{{\tt \rawbackslash \hat}#1}
  753. \let\file=\samp
  754. % @code is a modification of @t,
  755. % which makes spaces the same size as normal in the surrounding text.
  756. \newdimen\tclosesave
  757. \newdimen\tcloserm
  758. \def\tclose#1{{\rm \tcloserm=\fontdimen2\font \tt \tclosesave=\fontdimen2\font
  759. \fontdimen2\font=\tcloserm
  760. % prevent breaking lines at hyphens.
  761. \exhyphenpenalty=10000
  762. \def\ {{\fontdimen2\font=\tclosesave{} }}%
  763.  \rawbackslash \frenchspacing #1\fontdimen2\font=\tclosesave}\null}
  764. \let\code=\tclose
  765. %\let\exp=\tclose  %Was temporary
  766. % @kbd is like @code, except that if the argument is just one @key command, 
  767. % then @kbd has no effect.
  768. \def\xkey{\key}
  769. \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
  770. \ifx\one\xkey\ifx\threex\three \key{#2}%
  771. \else\tclose{\look}\fi
  772. \else\tclose{\look}\fi}
  773. % Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
  774. % argument is to make the input look right: @dmn{pt} instead of
  775. % @dmn{}pt.
  776. \def\dmn#1{\thinspace #1}
  777. \def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par}
  778. \def\l#1{{\li #1}\null}        % 
  779. \def\r#1{{\rm #1}}        % roman font
  780. % Use of \lowercase was suggested.
  781. \def\sc#1{{\smallcaps#1}}    % smallcaps font
  782. \def\ii#1{{\it #1}}        % italic font
  783. \message{page headings,}
  784. \newskip\titlepagetopglue \titlepagetopglue = 1.5in
  785. \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
  786. % First the title page.  Must do @settitle before @titlepage.
  787. \def\titlefont#1{{\titlerm #1}}
  788. \newtoks\realeverypar
  789. \newif\ifseenauthor
  790. \newif\iffinishedtitlepage
  791. \def\titlepage{\begingroup \parindent=0pt \textfonts
  792.    \let\subtitlerm=\tenrm
  793. % I deinstalled the following change because \cmr12 is undefined.
  794. % This change was not in the ChangeLog anyway.  --rms.
  795. %   \let\subtitlerm=\cmr12
  796.    \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}%
  797.    \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}%
  798.    % Leave some space at the very top of the page.
  799.    \vglue\titlepagetopglue
  800.    % Now you can print the title using @title.
  801.    \def\title{\parsearg\titlezzz}%
  802.    \def\titlezzz##1{\leftline{\titlefont{##1}}
  803.             % print a rule at the page bottom also.
  804.             \finishedtitlepagefalse
  805.             \vskip4pt \hrule height 4pt \vskip4pt}%
  806.    % No rule at page bottom unless we print one at the top with @title.
  807.    \finishedtitlepagetrue
  808.    % Now you can put text using @subtitle.
  809.    \def\subtitle{\parsearg\subtitlezzz}%
  810.    \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}%
  811.    % @author should come last, but may come many times.
  812.    \def\author{\parsearg\authorzzz}%
  813.    \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi
  814.       {\authorfont \leftline{##1}}}%
  815.    %  
  816.    % Most title ``pages'' are actually two pages long, with space
  817.    % at the top of the second.  We don't want the ragged left on the second.
  818.    \let\oldpage = \page
  819.    \def\page{%
  820.       \iffinishedtitlepage\else
  821.      \finishtitlepage
  822.       \fi
  823.       \oldpage
  824.       \let\page = \oldpage
  825.       \hbox{}}%
  826. %   \def\page{\oldpage \hbox{}}
  827. \def\Etitlepage{%
  828.    \iffinishedtitlepage\else
  829.       \finishtitlepage
  830.    \fi
  831.    % It is important to do the page break before ending the group,
  832.    % because the headline and footline are only empty inside the group.
  833.    % If we use the new definition of \page, we always get a blank page
  834.    % after the title page, which we certainly don't want.
  835.    \oldpage
  836.    \endgroup
  837.    \HEADINGSon
  838. \def\finishtitlepage{%
  839.    \vskip4pt \hrule height 2pt
  840.    \vskip\titlepagebottomglue
  841.    \finishedtitlepagetrue
  842. %%% Set up page headings and footings.
  843. \let\thispage=\folio
  844. \newtoks \evenheadline    % Token sequence for heading line of even pages
  845. \newtoks \oddheadline     % Token sequence for heading line of odd pages
  846. \newtoks \evenfootline    % Token sequence for footing line of even pages
  847. \newtoks \oddfootline     % Token sequence for footing line of odd pages
  848. % Now make Tex use those variables
  849. \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
  850.                             \else \the\evenheadline \fi}}
  851. \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
  852.                             \else \the\evenfootline \fi}\HEADINGShook}
  853. \let\HEADINGShook=\relax
  854. % Commands to set those variables.
  855. % For example, this is what  @headings on  does
  856. % @evenheading @thistitle|@thispage|@thischapter
  857. % @oddheading @thischapter|@thispage|@thistitle
  858. % @evenfooting @thisfile||
  859. % @oddfooting ||@thisfile
  860. \def\evenheading{\parsearg\evenheadingxxx}
  861. \def\oddheading{\parsearg\oddheadingxxx}
  862. \def\everyheading{\parsearg\everyheadingxxx}
  863. \def\evenfooting{\parsearg\evenfootingxxx}
  864. \def\oddfooting{\parsearg\oddfootingxxx}
  865. \def\everyfooting{\parsearg\everyfootingxxx}
  866. {\catcode`\@=0 %
  867. \gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish}
  868. \gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{%
  869. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  870. \gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish}
  871. \gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{%
  872. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  873. \gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish}
  874. \gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{%
  875. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
  876. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  877. \gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish}
  878. \gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{%
  879. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  880. \gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish}
  881. \gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{%
  882. \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  883. \gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish}
  884. \gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{%
  885. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
  886. \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  887. }% unbind the catcode of @.
  888. % @headings double    turns headings on for double-sided printing.
  889. % @headings single    turns headings on for single-sided printing.
  890. % @headings off        turns them off.
  891. % @headings on        same as @headings double, retained for compatibility.
  892. % @headings after    turns on double-sided headings after this page.
  893. % @headings doubleafter    turns on double-sided headings after this page.
  894. % @headings singleafter turns on single-sided headings after this page.
  895. % By default, they are off.
  896. \def\headings #1 {\csname HEADINGS#1\endcsname}
  897. \def\HEADINGSoff{
  898. \global\evenheadline={\hfil} \global\evenfootline={\hfil}
  899. \global\oddheadline={\hfil} \global\oddfootline={\hfil}}
  900. \HEADINGSoff
  901. % When we turn headings on, set the page number to 1.
  902. % For double-sided printing, put current file name in lower left corner,
  903. % chapter name on inside top of right hand pages, document
  904. % title on inside top of left hand pages, and page numbers on outside top
  905. % edge of all pages.
  906. \def\HEADINGSdouble{
  907. %\pagealignmacro
  908. \global\pageno=1
  909. \global\evenfootline={\hfil}
  910. \global\oddfootline={\hfil}
  911. \global\evenheadline={\line{\folio\hfil\thistitle}}
  912. \global\oddheadline={\line{\thischapter\hfil\folio}}
  913. % For single-sided printing, chapter title goes across top left of page,
  914. % page number on top right.
  915. \def\HEADINGSsingle{
  916. %\pagealignmacro
  917. \global\pageno=1
  918. \global\evenfootline={\hfil}
  919. \global\oddfootline={\hfil}
  920. \global\evenheadline={\line{\thischapter\hfil\folio}}
  921. \global\oddheadline={\line{\thischapter\hfil\folio}}
  922. \def\HEADINGSon{\HEADINGSdouble}
  923. \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
  924. \let\HEADINGSdoubleafter=\HEADINGSafter
  925. \def\HEADINGSdoublex{%
  926. \global\evenfootline={\hfil}
  927. \global\oddfootline={\hfil}
  928. \global\evenheadline={\line{\folio\hfil\thistitle}}
  929. \global\oddheadline={\line{\thischapter\hfil\folio}}
  930. \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
  931. \def\HEADINGSsinglex{%
  932. \global\evenfootline={\hfil}
  933. \global\oddfootline={\hfil}
  934. \global\evenheadline={\line{\thischapter\hfil\folio}}
  935. \global\oddheadline={\line{\thischapter\hfil\folio}}
  936. % Subroutines used in generating headings
  937. % Produces Day Month Year style of output.
  938. \def\today{\number\day\space
  939. \ifcase\month\or
  940. January\or February\or March\or April\or May\or June\or
  941. July\or August\or September\or October\or November\or December\fi
  942. \space\number\year}
  943. % Use this if you want the Month Day, Year style of output.
  944. %\def\today{\ifcase\month\or
  945. %January\or February\or March\or April\or May\or June\or
  946. %July\or August\or September\or October\or November\or December\fi
  947. %\space\number\day, \number\year}
  948. % @settitle line...  specifies the title of the document, for headings
  949. % It generates no output of its own
  950. \def\thistitle{No Title}
  951. \def\settitle{\parsearg\settitlezzz}
  952. \def\settitlezzz #1{\gdef\thistitle{#1}}
  953. \message{tables,}
  954. % @tabs -- simple alignment
  955. % These don't work.  For one thing, \+ is defined as outer.
  956. % So these macros cannot even be defined.
  957. %\def\tabs{\parsearg\tabszzz}
  958. %\def\tabszzz #1{\settabs\+#1\cr}
  959. %\def\tabline{\parsearg\tablinezzz}
  960. %\def\tablinezzz #1{\+#1\cr}
  961. %\def\&{&}
  962. % Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x).
  963. % default indentation of table text
  964. \newdimen\tableindent \tableindent=.8in
  965. % default indentation of @itemize and @enumerate text
  966. \newdimen\itemindent  \itemindent=.3in
  967. % margin between end of table item and start of table text.
  968. \newdimen\itemmargin  \itemmargin=.1in
  969. % used internally for \itemindent minus \itemmargin
  970. \newdimen\itemmax
  971. % Note @table, @vtable, and @vtable define @item, @itemx, etc., with
  972. % these defs.
  973. % They also define \itemindex
  974. % to index the item name in whatever manner is desired (perhaps none).
  975. \def\internalBitem{\smallbreak \parsearg\itemzzz}
  976. \def\internalBitemx{\par \parsearg\itemzzz}
  977. \def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz}
  978. \def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \par \parsearg\xitemzzz}
  979. \def\internalBkitem{\smallbreak \parsearg\kitemzzz}
  980. \def\internalBkitemx{\par \parsearg\kitemzzz}
  981. \def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}%
  982.                  \itemzzz {#1}}
  983. \def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}%
  984.                  \itemzzz {#1}}
  985. \def\itemzzz #1{\begingroup %
  986.   \advance\hsize by -\rightskip
  987.   \advance\hsize by -\tableindent
  988.   \setbox0=\hbox{\itemfont{#1}}%
  989.   \itemindex{#1}%
  990.   \nobreak % This prevents a break before @itemx.
  991.   % Be sure we are not still in the middle of a paragraph.
  992.   \parskip=0in
  993.   \par
  994.   % If the item text does not fit in the space we have, put it on a line
  995.   % by itself, and do not allow a page break either before or after that
  996.   % line.  We do not start a paragraph here because then if the next
  997.   % command is, e.g., @kindex, the whatsit would get put into the
  998.   % horizontal list on a line by itself, resulting in extra blank space.
  999.   \ifdim \wd0>\itemmax
  1000.     \setbox0=\hbox{\hskip \leftskip \hskip -\tableindent \unhbox0}\box0
  1001.     \nobreak
  1002.   \else
  1003.     % The item text fits into the space.  Start a paragraph, so that the
  1004.     % following text (if any) will end up on the same line.  Since that
  1005.     % text will be indented by \tableindent, we make the item text be in
  1006.     % a zero-width box.
  1007.     \noindent
  1008.     \rlap{\hskip -\tableindent\box0}%
  1009.   \fi
  1010.   \endgroup
  1011. \def\item{\errmessage{@item while not in a table}}
  1012. \def\itemx{\errmessage{@itemx while not in a table}}
  1013. \def\kitem{\errmessage{@kitem while not in a table}}
  1014. \def\kitemx{\errmessage{@kitemx while not in a table}}
  1015. \def\xitem{\errmessage{@xitem while not in a table}}
  1016. \def\xitemx{\errmessage{@xitemx while not in a table}}
  1017. %% Contains a kludge to get @end[description] to work
  1018. \def\description{\tablez{\dontindex}{1}{}{}{}{}}
  1019. \def\table{\begingroup\inENV\obeylines\obeyspaces\tablex}
  1020. {\obeylines\obeyspaces%
  1021. \gdef\tablex #1^^M{%
  1022. \tabley\dontindex#1        \endtabley}}
  1023. \def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex}
  1024. {\obeylines\obeyspaces%
  1025. \gdef\ftablex #1^^M{%
  1026. \tabley\fnitemindex#1        \endtabley
  1027. \def\Eftable{\endgraf\endgroup\afterenvbreak}%
  1028. \let\Etable=\relax}}
  1029. \def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex}
  1030. {\obeylines\obeyspaces%
  1031. \gdef\vtablex #1^^M{%
  1032. \tabley\vritemindex#1        \endtabley
  1033. \def\Evtable{\endgraf\endgroup\afterenvbreak}%
  1034. \let\Etable=\relax}}
  1035. \def\dontindex #1{}
  1036. \def\fnitemindex #1{\doind {fn}{\code{#1}}}%
  1037. \def\vritemindex #1{\doind {vr}{\code{#1}}}%
  1038. {\obeyspaces %
  1039. \gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup%
  1040. \tablez{#1}{#2}{#3}{#4}{#5}{#6}}}
  1041. \def\tablez #1#2#3#4#5#6{%
  1042. \aboveenvbreak %
  1043. \begingroup %
  1044. \def\Edescription{\Etable}% Neccessary kludge.
  1045. \let\itemindex=#1%
  1046. \ifnum 0#3>0 \advance \leftskip by #3\mil \fi %
  1047. \ifnum 0#4>0 \tableindent=#4\mil \fi %
  1048. \ifnum 0#5>0 \advance \rightskip by #5\mil \fi %
  1049. \def\itemfont{#2}%
  1050. \itemmax=\tableindent %
  1051. \advance \itemmax by -\itemmargin %
  1052. \advance \leftskip by \tableindent %
  1053. \exdentamount=\tableindent
  1054. \parindent = 0pt
  1055. \parskip = \smallskipamount
  1056. \ifdim \parskip=0pt \parskip=2pt \fi%
  1057. \def\Etable{\endgraf\endgroup\afterenvbreak}%
  1058. \let\item = \internalBitem %
  1059. \let\itemx = \internalBitemx %
  1060. \let\kitem = \internalBkitem %
  1061. \let\kitemx = \internalBkitemx %
  1062. \let\xitem = \internalBxitem %
  1063. \let\xitemx = \internalBxitemx %
  1064. % This is the counter used by @enumerate, which is really @itemize
  1065. \newcount \itemno
  1066. \def\itemize{\parsearg\itemizezzz}
  1067. \def\itemizezzz #1{%
  1068.   \begingroup % ended by the @end itemsize
  1069.   \itemizey {#1}{\Eitemize}
  1070. \def\itemizey #1#2{%
  1071. \aboveenvbreak %
  1072. \itemmax=\itemindent %
  1073. \advance \itemmax by -\itemmargin %
  1074. \advance \leftskip by \itemindent %
  1075. \exdentamount=\itemindent
  1076. \parindent = 0pt %
  1077. \parskip = \smallskipamount %
  1078. \ifdim \parskip=0pt \parskip=2pt \fi%
  1079. \def#2{\endgraf\endgroup\afterenvbreak}%
  1080. \def\itemcontents{#1}%
  1081. \let\item=\itemizeitem}
  1082. % Set sfcode to normal for the chars that usually have another value.
  1083. % These are `.?!:;,'
  1084. \def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000
  1085.   \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 }
  1086. % \splitoff TOKENS\endmark defines \first to be the first token in
  1087. % TOKENS, and \rest to be the remainder.
  1088. \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
  1089. % Allow an optional argument of an uppercase letter, lowercase letter,
  1090. % or number, to specify the first label in the enumerated list.  No
  1091. % argument is the same as `1'.
  1092. \def\enumerate{\parsearg\enumeratezzz}
  1093. \def\enumeratezzz #1{\enumeratey #1  \endenumeratey}
  1094. \def\enumeratey #1 #2\endenumeratey{%
  1095.   \begingroup % ended by the @end enumerate
  1096.   % If we were given no argument, pretend we were given `1'.
  1097.   \def\thearg{#1}%
  1098.   \ifx\thearg\empty \def\thearg{1}\fi
  1099.   % Detect if the argument is a single token.  If so, it might be a
  1100.   % letter.  Otherwise, the only valid thing it can be is a number.
  1101.   % (We will always have one token, because of the test we just made.
  1102.   % This is a good thing, since \splitoff doesn't work given nothing at
  1103.   % all -- the first parameter is undelimited.)
  1104.   \expandafter\splitoff\thearg\endmark
  1105.   \ifx\rest\empty
  1106.     % Only one token in the argument.  It could still be anything.
  1107.     % A ``lowercase letter'' is one whose \lccode is nonzero.
  1108.     % An ``uppercase letter'' is one whose \lccode is both nonzero, and
  1109.     %   not equal to itself.
  1110.     % Otherwise, we assume it's a number.
  1111.     % 
  1112.     % We need the \relax at the end of the \ifnum lines to stop TeX from
  1113.     % continuing to look for a <number>.
  1114.     % 
  1115.     \ifnum\lccode\expandafter`\thearg=0\relax 
  1116.       \numericenumerate % a number (we hope)
  1117.     \else
  1118.       % It's a letter.
  1119.       \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
  1120.         \lowercaseenumerate % lowercase letter
  1121.       \else
  1122.         \uppercaseenumerate % uppercase letter
  1123.       \fi
  1124.     \fi
  1125.   \else
  1126.     % Multiple tokens in the argument.  We hope it's a number.
  1127.     \numericenumerate
  1128.   \fi
  1129. % An @enumerate whose labels are integers.  The starting integer is
  1130. % given in \thearg.
  1131. \def\numericenumerate{%
  1132.   \itemno = \thearg
  1133.   \startenumeration{\the\itemno}%
  1134. % The starting (lowercase) letter is in \thearg.
  1135. \def\lowercaseenumerate{%
  1136.   \itemno = \expandafter`\thearg
  1137.   \startenumeration{%
  1138.     % Be sure we're not beyond the end of the alphabet.
  1139.     \ifnum\itemno=0
  1140.       \errmessage{No more lowercase letters in @enumerate; get a bigger
  1141.                   alphabet}%
  1142.     \fi
  1143.     \char\lccode\itemno
  1144. % The starting (uppercase) letter is in \thearg.
  1145. \def\uppercaseenumerate{%
  1146.   \itemno = \expandafter`\thearg
  1147.   \startenumeration{%
  1148.     % Be sure we're not beyond the end of the alphabet.
  1149.     \ifnum\itemno=0
  1150.       \errmessage{No more uppercase letters in @enumerate; get a bigger
  1151.                   alphabet}
  1152.     \fi
  1153.     \char\uccode\itemno
  1154. % Call itemizey, adding a period to the first argument and supplying the
  1155. % common last two arguments.  Also subtract one from the initial value in
  1156. % \itemno, since @item increments \itemno.
  1157. \def\startenumeration#1{%
  1158.   \advance\itemno by -1
  1159.   \itemizey{#1.}\Eenumerate\flushcr
  1160. % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
  1161. % to @enumerate.
  1162. \def\alphaenumerate{\enumerate{a}}
  1163. \def\capsenumerate{\enumerate{A}}
  1164. \def\Ealphaenumerate{\Eenumerate}
  1165. \def\Ecapsenumerate{\Eenumerate}
  1166. % Definition of @item while inside @itemize.
  1167. \def\itemizeitem{%
  1168. \advance\itemno by 1
  1169. {\let\par=\endgraf \smallbreak}%
  1170. \ifhmode \errmessage{\in hmode at itemizeitem}\fi
  1171. {\parskip=0in \hskip 0pt
  1172. \hbox to 0pt{\hss \itemcontents\hskip \itemmargin}%
  1173. \vadjust{\penalty 1200}}%
  1174. \flushcr}
  1175. \message{indexing,}
  1176. % Index generation facilities
  1177. % Define \newwrite to be identical to plain tex's \newwrite
  1178. % except not \outer, so it can be used within \newindex.
  1179. {\catcode`\@=11
  1180. \gdef\newwrite{\alloc@7\write\chardef\sixt@@n}}
  1181. % \newindex {foo} defines an index named foo.
  1182. % It automatically defines \fooindex such that
  1183. % \fooindex ...rest of line... puts an entry in the index foo.
  1184. % It also defines \fooindfile to be the number of the output channel for
  1185. % the file that    accumulates this index.  The file's extension is foo.
  1186. % The name of an index should be no more than 2 characters long
  1187. % for the sake of vms.
  1188. \def\newindex #1{
  1189. \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
  1190. \openout \csname#1indfile\endcsname \jobname.#1    % Open the file
  1191. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1192. \noexpand\doindex {#1}}
  1193. % @defindex foo  ==  \newindex{foo}
  1194. \def\defindex{\parsearg\newindex}
  1195. % Define @defcodeindex, like @defindex except put all entries in @code.
  1196. \def\newcodeindex #1{
  1197. \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
  1198. \openout \csname#1indfile\endcsname \jobname.#1    % Open the file
  1199. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1200. \noexpand\docodeindex {#1}}
  1201. \def\defcodeindex{\parsearg\newcodeindex}
  1202. % @synindex foo bar    makes index foo feed into index bar.
  1203. % Do this instead of @defindex foo if you don't want it as a separate index.
  1204. \def\synindex #1 #2 {%
  1205. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  1206. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  1207. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1208. \noexpand\doindex {#2}}%
  1209. % @syncodeindex foo bar   similar, but put all entries made for index foo
  1210. % inside @code.
  1211. \def\syncodeindex #1 #2 {%
  1212. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  1213. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  1214. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1215. \noexpand\docodeindex {#2}}%
  1216. % Define \doindex, the driver for all \fooindex macros.
  1217. % Argument #1 is generated by the calling \fooindex macro,
  1218. %  and it is "foo", the name of the index.
  1219. % \doindex just uses \parsearg; it calls \doind for the actual work.
  1220. % This is because \doind is more useful to call from other macros.
  1221. % There is also \dosubind {index}{topic}{subtopic}
  1222. % which makes an entry in a two-level index such as the operation index.
  1223. \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
  1224. \def\singleindexer #1{\doind{\indexname}{#1}}
  1225. % like the previous two, but they put @code around the argument.
  1226. \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
  1227. \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
  1228. \def\indexdummies{%
  1229. \def\_{{\realbackslash _}}%
  1230. \def\w{\realbackslash w }%
  1231. \def\bf{\realbackslash bf }%
  1232. \def\rm{\realbackslash rm }%
  1233. \def\sl{\realbackslash sl }%
  1234. \def\sf{\realbackslash sf}%
  1235. \def\tt{\realbackslash tt}%
  1236. \def\gtr{\realbackslash gtr}%
  1237. \def\less{\realbackslash less}%
  1238. \def\hat{\realbackslash hat}%
  1239. \def\char{\realbackslash char}%
  1240. \def\TeX{\realbackslash TeX}%
  1241. \def\dots{\realbackslash dots }%
  1242. \def\copyright{\realbackslash copyright }%
  1243. \def\tclose##1{\realbackslash tclose {##1}}%
  1244. \def\code##1{\realbackslash code {##1}}%
  1245. \def\samp##1{\realbackslash samp {##1}}%
  1246. \def\t##1{\realbackslash r {##1}}%
  1247. \def\r##1{\realbackslash r {##1}}%
  1248. \def\i##1{\realbackslash i {##1}}%
  1249. \def\b##1{\realbackslash b {##1}}%
  1250. \def\cite##1{\realbackslash cite {##1}}%
  1251. \def\key##1{\realbackslash key {##1}}%
  1252. \def\file##1{\realbackslash file {##1}}%
  1253. \def\var##1{\realbackslash var {##1}}%
  1254. \def\kbd##1{\realbackslash kbd {##1}}%
  1255. % \indexnofonts no-ops all font-change commands.
  1256. % This is used when outputting the strings to sort the index by.
  1257. \def\indexdummyfont#1{#1}
  1258. \def\indexdummytex{TeX}
  1259. \def\indexdummydots{...}
  1260. \def\indexnofonts{%
  1261. \let\w=\indexdummyfont
  1262. \let\t=\indexdummyfont
  1263. \let\r=\indexdummyfont
  1264. \let\i=\indexdummyfont
  1265. \let\b=\indexdummyfont
  1266. \let\emph=\indexdummyfont
  1267. \let\strong=\indexdummyfont
  1268. \let\cite=\indexdummyfont
  1269. \let\sc=\indexdummyfont
  1270. %Don't no-op \tt, since it isn't a user-level command
  1271. % and is used in the definitions of the active chars like <, >, |...
  1272. %\let\tt=\indexdummyfont
  1273. \let\tclose=\indexdummyfont
  1274. \let\code=\indexdummyfont
  1275. \let\file=\indexdummyfont
  1276. \let\samp=\indexdummyfont
  1277. \let\kbd=\indexdummyfont
  1278. \let\key=\indexdummyfont
  1279. \let\var=\indexdummyfont
  1280. \let\TeX=\indexdummytex
  1281. \let\dots=\indexdummydots
  1282. % To define \realbackslash, we must make \ not be an escape.
  1283. % We must first make another character (@) an escape
  1284. % so we do not become unable to do a definition.
  1285. {\catcode`\@=0 \catcode`\\=\other
  1286. @gdef@realbackslash{\}}
  1287. \let\indexbackslash=0  %overridden during \printindex.
  1288. \def\doind #1#2{%
  1289. {\count10=\lastpenalty %
  1290. {\indexdummies % Must do this here, since \bf, etc expand at this stage
  1291. \escapechar=`\\%
  1292. {\let\folio=0% Expand all macros now EXCEPT \folio
  1293. \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
  1294. % so it will be output as is; and it will print as backslash in the indx.
  1295. % Now process the index-string once, with all font commands turned off,
  1296. % to get the string to sort the index by.
  1297. {\indexnofonts
  1298. \xdef\temp1{#2}%
  1299. % Now produce the complete index entry.  We process the index-string again,
  1300. % this time with font commands expanded, to get what to print in the index.
  1301. \edef\temp{%
  1302. \write \csname#1indfile\endcsname{%
  1303. \realbackslash entry {\temp1}{\folio}{#2}}}%
  1304. \temp }%
  1305. }\penalty\count10}}
  1306. \def\dosubind #1#2#3{%
  1307. {\count10=\lastpenalty %
  1308. {\indexdummies % Must do this here, since \bf, etc expand at this stage
  1309. \escapechar=`\\%
  1310. {\let\folio=0%
  1311. \def\rawbackslashxx{\indexbackslash}%
  1312. % Now process the index-string once, with all font commands turned off,
  1313. % to get the string to sort the index by.
  1314. {\indexnofonts
  1315. \xdef\temp1{#2 #3}%
  1316. % Now produce the complete index entry.  We process the index-string again,
  1317. % this time with font commands expanded, to get what to print in the index.
  1318. \edef\temp{%
  1319. \write \csname#1indfile\endcsname{%
  1320. \realbackslash entry {\temp1}{\folio}{#2}{#3}}}%
  1321. \temp }%
  1322. }\penalty\count10}}
  1323. % The index entry written in the file actually looks like
  1324. %  \entry {sortstring}{page}{topic}
  1325. %  \entry {sortstring}{page}{topic}{subtopic}
  1326. % The texindex program reads in these files and writes files
  1327. % containing these kinds of lines:
  1328. %  \initial {c}
  1329. %     before the first topic whose initial is c
  1330. %  \entry {topic}{pagelist}
  1331. %     for a topic that is used without subtopics
  1332. %  \primary {topic}
  1333. %     for the beginning of a topic that is used with subtopics
  1334. %  \secondary {subtopic}{pagelist}
  1335. %     for each subtopic.
  1336. % Define the user-accessible indexing commands 
  1337. % @findex, @vindex, @kindex, @cindex.
  1338. \def\findex {\fnindex}
  1339. \def\kindex {\kyindex}
  1340. \def\cindex {\cpindex}
  1341. \def\vindex {\vrindex}
  1342. \def\tindex {\tpindex}
  1343. \def\pindex {\pgindex}
  1344. \def\cindexsub {\begingroup\obeylines\cindexsub}
  1345. {\obeylines %
  1346. \gdef\cindexsub "#1" #2^^M{\endgroup %
  1347. \dosubind{cp}{#2}{#1}}}
  1348. % Define the macros used in formatting output of the sorted index material.
  1349. % This is what you call to cause a particular index to get printed.
  1350. % Write
  1351. % @unnumbered Function Index
  1352. % @printindex fn
  1353. \def\printindex{\parsearg\doprintindex}
  1354. \def\doprintindex#1{%
  1355.   \tex
  1356.   \dobreak \chapheadingskip {10000}
  1357.   \catcode`\%=\other\catcode`\&=\other\catcode`\#=\other
  1358.   \catcode`\$=\other\catcode`\_=\other
  1359.   \catcode`\~=\other
  1360.   % The following don't help, since the chars were translated
  1361.   % when the raw index was written, and their fonts were discarded
  1362.   % due to \indexnofonts.
  1363.   %\catcode`\"=\active
  1364.   %\catcode`\^=\active
  1365.   %\catcode`\_=\active
  1366.   %\catcode`\|=\active
  1367.   %\catcode`\<=\active
  1368.   %\catcode`\>=\active
  1369.   % %
  1370.   \def\indexbackslash{\rawbackslashxx}
  1371.   \indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt
  1372.   \begindoublecolumns
  1373.   % See if the index file exists and is nonempty.
  1374.   \openin 1 \jobname.#1s
  1375.   \ifeof 1 
  1376.     % \enddoublecolumns gets confused if there is no text in the index,
  1377.     % and it loses the chapter title and the aux file entries for the
  1378.     % index.  The easiest way to prevent this problem is to make sure
  1379.     % there is some text.
  1380.     (Index is nonexistent)
  1381.     \else
  1382.     %
  1383.     % If the index file exists but is empty, then \openin leaves \ifeof
  1384.     % false.  We have to make TeX try to read something from the file, so
  1385.     % it can discover if there is anything in it.
  1386.     \read 1 to \temp
  1387.     \ifeof 1
  1388.       (Index is empty)
  1389.     \else
  1390.       \input \jobname.#1s
  1391.     \fi
  1392.   \fi
  1393.   \closein 1
  1394.   \enddoublecolumns
  1395.   \Etex
  1396. % These macros are used by the sorted index file itself.
  1397. % Change them to control the appearance of the index.
  1398. % Same as \bigskipamount except no shrink.
  1399. % \balancecolumns gets confused if there is any shrink.
  1400. \newskip\initialskipamount \initialskipamount 12pt plus4pt
  1401. \def\initial #1{%
  1402. {\let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
  1403. \ifdim\lastskip<\initialskipamount
  1404. \removelastskip \penalty-200 \vskip \initialskipamount\fi
  1405. \line{\secbf#1\hfill}\kern 2pt\penalty10000}}
  1406. % This typesets a paragraph consisting of #1, dot leaders, and then #2
  1407. % flush to the right margin.  It is used for index and table of contents
  1408. % entries.  The paragraph is indented by \leftskip.
  1409. \def\entry #1#2{\begingroup
  1410.   % Start a new paragraph if necessary, so our assignments below can't
  1411.   % affect previous text.
  1412.   \par
  1413.   % Do not fill out the last line with white space.
  1414.   \parfillskip = 0in
  1415.   % No extra space above this paragraph.
  1416.   \parskip = 0in
  1417.   % Do not prefer a separate line ending with a hyphen to fewer lines.
  1418.   \finalhyphendemerits = 0
  1419.   % \hangindent is only relevant when the entry text and page number
  1420.   % don't both fit on one line.  In that case, bob suggests starting the
  1421.   % dots pretty far over on the line.  Unfortunately, a large
  1422.   % indentation looks wrong when the entry text itself is broken across
  1423.   % lines.  So we use a small indentation and put up with long leaders.
  1424.   % \hangafter is reset to 1 (which is the value we want) at the start
  1425.   % of each paragraph, so we need not do anything with that.
  1426.   \hangindent=2em
  1427.   % When the entry text needs to be broken, just fill out the first line
  1428.   % with blank space.
  1429.   \rightskip = 0pt plus1fil
  1430.   % Start a ``paragraph'' for the index entry so the line breaking
  1431.   % parameters we've set above will have an effect.
  1432.   \noindent
  1433.   % Insert the text of the index entry.  TeX will do line-breaking on it.
  1434.   #1%
  1435.   % If we must, put the page number on a line of its own, and fill out
  1436.   % this line with blank space.  (The \hfil is overwhelmed with the
  1437.   % fill leaders glue in \indexdotfill if the page number does fit.)
  1438.   \hfil\penalty50
  1439.   \null\nobreak\indexdotfill % Have leaders before the page number.
  1440.   % The `\ ' here is removed by the implicit \unskip that TeX does as
  1441.   % part of (the primitive) \par.  Without it, a spurious underfull
  1442.   % \hbox ensues.
  1443.   \ #2% The page number ends the paragraph.
  1444.   \par
  1445. \endgroup}
  1446. % Like \dotfill except takes at least 1 em.
  1447. \def\indexdotfill{\cleaders
  1448.   \hbox{$\mathsurround=0pt \mkern1.5mu . \mkern1.5mu$}\hskip 1em plus 1fill}
  1449. \def\primary #1{\line{#1\hfil}}
  1450. \newskip\secondaryindent \secondaryindent=0.5cm
  1451. \def\secondary #1#2{
  1452. {\parfillskip=0in \parskip=0in
  1453. \hangindent =1in \hangafter=1
  1454. \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par
  1455. %% Define two-column mode, which is used in indexes.
  1456. %% Adapted from the TeXbook, page 416.
  1457. \catcode `\@=11
  1458. \newbox\partialpage
  1459. \newdimen\doublecolumnhsize
  1460. \def\begindoublecolumns{\begingroup
  1461.   % Grab any single-column material above us.
  1462.   \output = {\global\setbox\partialpage
  1463.     =\vbox{\unvbox255\kern -\topskip \kern \baselineskip}}%
  1464.   \eject
  1465.   % Now switch to the double-column output routine.
  1466.   \output={\doublecolumnout}%
  1467.   % Change the page size parameters.  We could do this once outside this
  1468.   % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
  1469.   % format, but then we repeat the same computation.  Repeating a couple
  1470.   % of assignments once per index is clearly meaningless for the
  1471.   % execution time, so we may as well do it once.
  1472.   % First we halve the line length, less a little for the gutter between
  1473.   % the columns.  We compute the gutter based on the line length, so it
  1474.   % changes automatically with the paper format.  The magic constant
  1475.   % below is chosen so that the gutter has the same value (well, +- <
  1476.   % 1pt) as it did when we hard-coded it.
  1477.   % We put the result in a separate register, \doublecolumhsize, so we
  1478.   % can restore it in \pagesofar, after \hsize itself has (potentially)
  1479.   % been clobbered.
  1480.   \doublecolumnhsize = \hsize
  1481.     \advance\doublecolumnhsize by -.04154\hsize
  1482.     \divide\doublecolumnhsize by 2
  1483.   \hsize = \doublecolumnhsize
  1484.   % Double the \vsize as well.  (We don't need a separate register here,
  1485.   % since nobody clobbers \vsize.)
  1486.   \vsize = 2\vsize
  1487.   \doublecolumnpagegoal
  1488. \def\enddoublecolumns{\eject \endgroup \pagegoal=\vsize \unvbox\partialpage}
  1489. \def\doublecolumnsplit{\splittopskip=\topskip \splitmaxdepth=\maxdepth
  1490.   \global\dimen@=\pageheight \global\advance\dimen@ by-\ht\partialpage
  1491.   \global\setbox1=\vsplit255 to\dimen@ \global\setbox0=\vbox{\unvbox1}
  1492.   \global\setbox3=\vsplit255 to\dimen@ \global\setbox2=\vbox{\unvbox3}
  1493.   \ifdim\ht0>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi
  1494.   \ifdim\ht2>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi
  1495. \def\doublecolumnpagegoal{%
  1496.   \dimen@=\vsize \advance\dimen@ by-2\ht\partialpage \global\pagegoal=\dimen@
  1497. \def\pagesofar{\unvbox\partialpage %
  1498.   \hsize=\doublecolumnhsize % have to restore this since output routine
  1499.   \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}}
  1500. \def\doublecolumnout{%
  1501.   \setbox5=\copy255
  1502.   {\vbadness=10000 \doublecolumnsplit}
  1503.   \ifvbox255
  1504.     \setbox0=\vtop to\dimen@{\unvbox0}
  1505.     \setbox2=\vtop to\dimen@{\unvbox2}
  1506.     \onepageout\pagesofar \unvbox255 \penalty\outputpenalty
  1507.   \else
  1508.     \setbox0=\vbox{\unvbox5}
  1509.     \ifvbox0
  1510.       \dimen@=\ht0 \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
  1511.       \divide\dimen@ by2 \splittopskip=\topskip \splitmaxdepth=\maxdepth
  1512.       {\vbadness=10000
  1513.     \loop \global\setbox5=\copy0
  1514.           \setbox1=\vsplit5 to\dimen@
  1515.           \setbox3=\vsplit5 to\dimen@
  1516.           \ifvbox5 \global\advance\dimen@ by1pt \repeat
  1517.         \setbox0=\vbox to\dimen@{\unvbox1}
  1518.         \setbox2=\vbox to\dimen@{\unvbox3}
  1519.         \global\setbox\partialpage=\vbox{\pagesofar}
  1520.         \doublecolumnpagegoal
  1521.       }
  1522.     \fi
  1523.   \fi
  1524. \catcode `\@=\other
  1525. \message{sectioning,}
  1526. % Define chapters, sections, etc.
  1527. \newcount \chapno
  1528. \newcount \secno        \secno=0
  1529. \newcount \subsecno     \subsecno=0
  1530. \newcount \subsubsecno  \subsubsecno=0
  1531. % This counter is funny since it counts through charcodes of letters A, B, ...
  1532. \newcount \appendixno  \appendixno = `\@
  1533. \def\appendixletter{\char\the\appendixno}
  1534. \newwrite \contentsfile
  1535. % This is called from \setfilename.
  1536. \def\opencontents{\openout \contentsfile = \jobname.toc}
  1537. % Each @chapter defines this as the name of the chapter.
  1538. % page headings and footings can use it.  @section does likewise
  1539. \def\thischapter{} \def\thissection{}
  1540. \def\seccheck#1{\if \pageno<0 %
  1541. \errmessage{@#1 not allowed after generating table of contents}\fi
  1542. \def\chapternofonts{%
  1543. \let\rawbackslash=\relax%
  1544. \let\frenchspacing=\relax%
  1545. \def\result{\realbackslash result}
  1546. \def\equiv{\realbackslash equiv}
  1547. \def\expansion{\realbackslash expansion}
  1548. \def\print{\realbackslash print}
  1549. \def\TeX{\realbackslash TeX}
  1550. \def\dots{\realbackslash dots}
  1551. \def\copyright{\realbackslash copyright}
  1552. \def\tt{\realbackslash tt}
  1553. \def\bf{\realbackslash bf }
  1554. \def\w{\realbackslash w}
  1555. \def\less{\realbackslash less}
  1556. \def\gtr{\realbackslash gtr}
  1557. \def\hat{\realbackslash hat}
  1558. \def\char{\realbackslash char}
  1559. \def\tclose##1{\realbackslash tclose {##1}}
  1560. \def\code##1{\realbackslash code {##1}}
  1561. \def\samp##1{\realbackslash samp {##1}}
  1562. \def\r##1{\realbackslash r {##1}}
  1563. \def\b##1{\realbackslash b {##1}}
  1564. \def\key##1{\realbackslash key {##1}}
  1565. \def\file##1{\realbackslash file {##1}}
  1566. \def\kbd##1{\realbackslash kbd {##1}}
  1567. % These are redefined because @smartitalic wouldn't work inside xdef.
  1568. \def\i##1{\realbackslash i {##1}}
  1569. \def\cite##1{\realbackslash cite {##1}}
  1570. \def\var##1{\realbackslash var {##1}}
  1571. \def\emph##1{\realbackslash emph {##1}}
  1572. \def\dfn##1{\realbackslash dfn {##1}}
  1573. \def\thischaptername{No Chapter Title}
  1574. \outer\def\chapter{\parsearg\chapterzzz}
  1575. \def\chapterzzz #1{\seccheck{chapter}%
  1576. \secno=0 \subsecno=0 \subsubsecno=0
  1577. \global\advance \chapno by 1 \message{Chapter \the\chapno}%
  1578. \chapmacro {#1}{\the\chapno}%
  1579. \gdef\thissection{#1}%
  1580. \gdef\thischaptername{#1}%
  1581. % We don't substitute the actual chapter name into \thischapter
  1582. % because we don't want its macros evaluated now.
  1583. \xdef\thischapter{Chapter \the\chapno: \noexpand\thischaptername}%
  1584. {\chapternofonts%
  1585. \edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}%
  1586. \escapechar=`\\%
  1587. \write \contentsfile \temp  %
  1588. \donoderef %
  1589. \global\let\section = \numberedsec
  1590. \global\let\subsection = \numberedsubsec
  1591. \global\let\subsubsection = \numberedsubsubsec
  1592. \outer\def\appendix{\parsearg\appendixzzz}
  1593. \def\appendixzzz #1{\seccheck{appendix}%
  1594. \secno=0 \subsecno=0 \subsubsecno=0
  1595. \global\advance \appendixno by 1 \message{Appendix \appendixletter}%
  1596. \chapmacro {#1}{Appendix \appendixletter}%
  1597. \gdef\thissection{#1}%
  1598. \gdef\thischaptername{#1}%
  1599. \xdef\thischapter{Appendix \appendixletter: \noexpand\thischaptername}%
  1600. {\chapternofonts%
  1601. \edef\temp{{\realbackslash chapentry 
  1602.   {#1}{Appendix \appendixletter}{\noexpand\folio}}}%
  1603. \escapechar=`\\%
  1604. \write \contentsfile \temp  %
  1605. \appendixnoderef %
  1606. \global\let\section = \appendixsec
  1607. \global\let\subsection = \appendixsubsec
  1608. \global\let\subsubsection = \appendixsubsubsec
  1609. \outer\def\top{\parsearg\unnumberedzzz}
  1610. \outer\def\unnumbered{\parsearg\unnumberedzzz}
  1611. \def\unnumberedzzz #1{\seccheck{unnumbered}%
  1612. \secno=0 \subsecno=0 \subsubsecno=0
  1613. % This used to be simply \message{#1}, but TeX fully expands the
  1614. % argument to \message.  Therefore, if #1 contained @-commands, TeX
  1615. % expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
  1616. % expanded @cite (which turns out to cause errors because \cite is meant
  1617. % to be executed, not expanded).  
  1618. % Anyway, we don't want the fully-expanded definition of @cite to appear
  1619. % as a result of the \message, we just want `@cite' itself.  We use
  1620. % \the<toks register> to achieve this: TeX expands \the<toks> only once,
  1621. % simply yielding the contents of the <toks register>.
  1622. \toks0 = {#1}\message{(\the\toks0)}%
  1623. \unnumbchapmacro {#1}%
  1624. \gdef\thischapter{#1}\gdef\thissection{#1}%
  1625. {\chapternofonts%
  1626. \edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}%
  1627. \escapechar=`\\%
  1628. \write \contentsfile \temp  %
  1629. \unnumbnoderef %
  1630. \global\let\section = \unnumberedsec
  1631. \global\let\subsection = \unnumberedsubsec
  1632. \global\let\subsubsection = \unnumberedsubsubsec
  1633. \outer\def\numberedsec{\parsearg\seczzz}
  1634. \def\seczzz #1{\seccheck{section}%
  1635. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  1636. \gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
  1637. {\chapternofonts%
  1638. \edef\temp{{\realbackslash secentry %
  1639. {#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}%
  1640. \escapechar=`\\%
  1641. \write \contentsfile \temp %
  1642. \donoderef %
  1643. \penalty 10000 %
  1644. \outer\def\appendixsection{\parsearg\appendixsectionzzz}
  1645. \outer\def\appendixsec{\parsearg\appendixsectionzzz}
  1646. \def\appendixsectionzzz #1{\seccheck{appendixsection}%
  1647. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  1648. \gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
  1649. {\chapternofonts%
  1650. \edef\temp{{\realbackslash secentry %
  1651. {#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}%
  1652. \escapechar=`\\%
  1653. \write \contentsfile \temp %
  1654. \appendixnoderef %
  1655. \penalty 10000 %
  1656. \outer\def\unnumberedsec{\parsearg\unnumberedseczzz}
  1657. \def\unnumberedseczzz #1{\seccheck{unnumberedsec}%
  1658. \plainsecheading {#1}\gdef\thissection{#1}%
  1659. {\chapternofonts%
  1660. \edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}%
  1661. \escapechar=`\\%
  1662. \write \contentsfile \temp %
  1663. \unnumbnoderef %
  1664. \penalty 10000 %
  1665. \outer\def\numberedsubsec{\parsearg\numberedsubseczzz}
  1666. \def\numberedsubseczzz #1{\seccheck{subsection}%
  1667. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  1668. \subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
  1669. {\chapternofonts%
  1670. \edef\temp{{\realbackslash subsecentry %
  1671. {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
  1672. \escapechar=`\\%
  1673. \write \contentsfile \temp %
  1674. \donoderef %
  1675. \penalty 10000 %
  1676. \outer\def\appendixsubsec{\parsearg\appendixsubseczzz}
  1677. \def\appendixsubseczzz #1{\seccheck{appendixsubsec}%
  1678. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  1679. \subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
  1680. {\chapternofonts%
  1681. \edef\temp{{\realbackslash subsecentry %
  1682. {#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
  1683. \escapechar=`\\%
  1684. \write \contentsfile \temp %
  1685. \appendixnoderef %
  1686. \penalty 10000 %
  1687. \outer\def\unnumberedsubsec{\parsearg\unnumberedsubseczzz}
  1688. \def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}%
  1689. \plainsecheading {#1}\gdef\thissection{#1}%
  1690. {\chapternofonts%
  1691. \edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}%
  1692. \escapechar=`\\%
  1693. \write \contentsfile \temp %
  1694. \unnumbnoderef %
  1695. \penalty 10000 %
  1696. \outer\def\numberedsubsubsec{\parsearg\numberedsubsubseczzz}
  1697. \def\numberedsubsubseczzz #1{\seccheck{subsubsection}%
  1698. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  1699. \subsubsecheading {#1}
  1700.   {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  1701. {\chapternofonts%
  1702. \edef\temp{{\realbackslash subsubsecentry %
  1703.   {#1}
  1704.   {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}
  1705.   {\noexpand\folio}}}%
  1706. \escapechar=`\\%
  1707. \write \contentsfile \temp %
  1708. \donoderef %
  1709. \penalty 10000 %
  1710. \outer\def\appendixsubsubsec{\parsearg\appendixsubsubseczzz}
  1711. \def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}%
  1712. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  1713. \subsubsecheading {#1}
  1714.   {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  1715. {\chapternofonts%
  1716. \edef\temp{{\realbackslash subsubsecentry{#1}%
  1717.   {\appendixletter}
  1718.   {\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}%
  1719. \escapechar=`\\%
  1720. \write \contentsfile \temp %
  1721. \appendixnoderef %
  1722. \penalty 10000 %
  1723. \outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
  1724. \def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}%
  1725. \plainsecheading {#1}\gdef\thissection{#1}%
  1726. {\chapternofonts%
  1727. \edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}%
  1728. \escapechar=`\\%
  1729. \write \contentsfile \temp %
  1730. \unnumbnoderef %
  1731. \penalty 10000 %
  1732. % These are variants which are not "outer", so they can appear in @ifinfo.
  1733. % Actually, they should now be obsolete; ordinary section commands should work.
  1734. \def\infotop{\parsearg\unnumberedzzz}
  1735. \def\infounnumbered{\parsearg\unnumberedzzz}
  1736. \def\infounnumberedsec{\parsearg\unnumberedseczzz}
  1737. \def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
  1738. \def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
  1739. \def\infoappendix{\parsearg\appendixzzz}
  1740. \def\infoappendixsec{\parsearg\appendixseczzz}
  1741. \def\infoappendixsubsec{\parsearg\appendixsubseczzz}
  1742. \def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
  1743. \def\infochapter{\parsearg\chapterzzz}
  1744. \def\infosection{\parsearg\sectionzzz}
  1745. \def\infosubsection{\parsearg\subsectionzzz}
  1746. \def\infosubsubsection{\parsearg\subsubsectionzzz}
  1747. % These macros control what the section commands do, according
  1748. % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
  1749. % Define them by default for a numbered chapter.
  1750. \global\let\section = \numberedsec
  1751. \global\let\subsection = \numberedsubsec
  1752. \global\let\subsubsection = \numberedsubsubsec
  1753. % Define @majorheading, @heading and @subheading
  1754. % NOTE on use of \vbox for chapter headings, section headings, and
  1755. % such:
  1756. %    1) We use \vbox rather than the earlier \line to permit
  1757. %       overlong headings to fold.
  1758. %    2) \hyphenpenalty is set to 10000 because hyphenation in a
  1759. %       heading is obnoxious; this forbids it.
  1760. %       3) Likewise, headings look best if no \parindent is used, and
  1761. %          if justification is not attempted.  Hence \raggedright.
  1762. \def\majorheading{\parsearg\majorheadingzzz}
  1763. \def\majorheadingzzz #1{%
  1764. {\advance\chapheadingskip by 10pt \chapbreak }%
  1765. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1766.                   \parindent=0pt\raggedright
  1767.                   \rm #1\hfill}}\bigskip \par\penalty 200}
  1768. \def\chapheading{\parsearg\chapheadingzzz}
  1769. \def\chapheadingzzz #1{\chapbreak %
  1770. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1771.                   \parindent=0pt\raggedright
  1772.                   \rm #1\hfill}}\bigskip \par\penalty 200}
  1773. \def\heading{\parsearg\secheadingi}
  1774. \def\subheading{\parsearg\subsecheadingi}
  1775. \def\subsubheading{\parsearg\subsubsecheadingi}
  1776. % These macros generate a chapter, section, etc. heading only
  1777. % (including whitespace, linebreaking, etc. around it),
  1778. % given all the information in convenient, parsed form.
  1779. %%% Args are the skip and penalty (usually negative)
  1780. \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
  1781. \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
  1782. %%% Define plain chapter starts, and page on/off switching for it
  1783. % Parameter controlling skip before chapter headings (if needed)
  1784. \newskip \chapheadingskip \chapheadingskip = 30pt plus 8pt minus 4pt
  1785. \def\chapbreak{\dobreak \chapheadingskip {-4000}}
  1786. \def\chappager{\par\vfill\supereject}
  1787. \def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
  1788. \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
  1789. \def\CHAPPAGoff{
  1790. \global\let\pchapsepmacro=\chapbreak
  1791. \global\let\pagealignmacro=\chappager}
  1792. \def\CHAPPAGon{
  1793. \global\let\pchapsepmacro=\chappager
  1794. \global\let\pagealignmacro=\chappager
  1795. \global\def\HEADINGSon{\HEADINGSsingle}}
  1796. \def\CHAPPAGodd{
  1797. \global\let\pchapsepmacro=\chapoddpage
  1798. \global\let\pagealignmacro=\chapoddpage
  1799. \global\def\HEADINGSon{\HEADINGSdouble}}
  1800. \CHAPPAGon
  1801. \def\CHAPFplain{
  1802. \global\let\chapmacro=\chfplain
  1803. \global\let\unnumbchapmacro=\unnchfplain}
  1804. \def\chfplain #1#2{%
  1805.   \pchapsepmacro
  1806.     \chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1807.                      \parindent=0pt\raggedright
  1808.                      \rm #2\enspace #1}%
  1809.   \bigskip
  1810.   \penalty5000
  1811. \def\unnchfplain #1{%
  1812. \pchapsepmacro %
  1813. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1814.                   \parindent=0pt\raggedright
  1815.                   \rm #1\hfill}}\bigskip \par\penalty 10000 %
  1816. \CHAPFplain % The default
  1817. \def\unnchfopen #1{%
  1818. \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1819.                        \parindent=0pt\raggedright
  1820.                        \rm #1\hfill}}\bigskip \par\penalty 10000 %
  1821. \def\chfopen #1#2{\chapoddpage {\chapfonts
  1822. \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
  1823. \par\penalty 5000 %
  1824. \def\CHAPFopen{
  1825. \global\let\chapmacro=\chfopen
  1826. \global\let\unnumbchapmacro=\unnchfopen}
  1827. % Parameter controlling skip before section headings.
  1828. \newskip \subsecheadingskip  \subsecheadingskip = 17pt plus 8pt minus 4pt
  1829. \def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
  1830. \newskip \secheadingskip  \secheadingskip = 21pt plus 8pt minus 4pt
  1831. \def\secheadingbreak{\dobreak \secheadingskip {-1000}}
  1832. % @paragraphindent  is defined for the Info formatting commands only.
  1833. \let\paragraphindent=\comment
  1834. % Section fonts are the base font at magstep2, which produces
  1835. % a size a bit more than 14 points in the default situation.    
  1836. \def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}}
  1837. \def\plainsecheading #1{\secheadingi {#1}}
  1838. \def\secheadingi #1{{\advance \secheadingskip by \parskip %
  1839. \secheadingbreak}%
  1840. {\secfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1841.                  \parindent=0pt\raggedright
  1842.                  \rm #1\hfill}}%
  1843. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
  1844. % Subsection fonts are the base font at magstep1, 
  1845. % which produces a size of 12 points.
  1846. \def\subsecheading #1#2#3#4{\subsecheadingi {#2.#3.#4\enspace #1}}
  1847. \def\subsecheadingi #1{{\advance \subsecheadingskip by \parskip %
  1848. \subsecheadingbreak}%
  1849. {\subsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1850.                      \parindent=0pt\raggedright
  1851.                      \rm #1\hfill}}%
  1852. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
  1853. \def\subsubsecfonts{\subsecfonts} % Maybe this should change:
  1854.                   % Perhaps make sssec fonts scaled
  1855.                   % magstep half
  1856. \def\subsubsecheading #1#2#3#4#5{\subsubsecheadingi {#2.#3.#4.#5\enspace #1}}
  1857. \def\subsubsecheadingi #1{{\advance \subsecheadingskip by \parskip %
  1858. \subsecheadingbreak}%
  1859. {\subsubsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1860.                        \parindent=0pt\raggedright
  1861.                        \rm #1\hfill}}%
  1862. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000}
  1863. \message{toc printing,}
  1864. % Finish up the main text and prepare to read what we've written
  1865. % to \contentsfile.
  1866. \newskip\contentsrightmargin \contentsrightmargin=1in
  1867. \def\startcontents#1{%
  1868.    \pagealignmacro
  1869.    \immediate\closeout \contentsfile
  1870.    \ifnum \pageno>0
  1871.       \pageno = -1        % Request roman numbered pages.
  1872.    \fi
  1873.    % Don't need to put `Contents' or `Short Contents' in the headline. 
  1874.    % It is abundantly clear what they are.
  1875.    \unnumbchapmacro{#1}\def\thischapter{}%
  1876.    \begingroup           % Set up to handle contents files properly.
  1877.       \catcode`\\=0  \catcode`\{=1  \catcode`\}=2  \catcode`\@=11
  1878.       \raggedbottom             % Worry more about breakpoints than the bottom.
  1879.       \advance\hsize by -\contentsrightmargin % Don't use the full line length.
  1880. % Normal (long) toc.
  1881. \outer\def\contents{%
  1882.    \startcontents{Table of Contents}%
  1883.       \input \jobname.toc
  1884.    \endgroup
  1885.    \vfill \eject
  1886. % And just the chapters.
  1887. \outer\def\summarycontents{%
  1888.    \startcontents{Short Contents}%
  1889.       %
  1890.       \let\chapentry = \shortchapentry
  1891.       \let\unnumbchapentry = \shortunnumberedentry
  1892.       % We want a true roman here for the page numbers.
  1893.       \secfonts
  1894.       \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl
  1895.       \rm
  1896.       \advance\baselineskip by 1pt % Open it up a little.
  1897.       \def\secentry ##1##2##3##4{}
  1898.       \def\unnumbsecentry ##1##2{}
  1899.       \def\subsecentry ##1##2##3##4##5{}
  1900.       \def\unnumbsubsecentry ##1##2{}
  1901.       \def\subsubsecentry ##1##2##3##4##5##6{}
  1902.       \def\unnumbsubsubsecentry ##1##2{}
  1903.       \input \jobname.toc
  1904.    \endgroup
  1905.    \vfill \eject
  1906. \let\shortcontents = \summarycontents
  1907. % These macros generate individual entries in the table of contents.
  1908. % The first argument is the chapter or section name.
  1909. % The last argument is the page number.
  1910. % The arguments in between are the chapter number, section number, ...
  1911. % Chapter-level things, for both the long and short contents.
  1912. \def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}}
  1913. % See comments in \dochapentry re vbox and related settings
  1914. \def\shortchapentry#1#2#3{%
  1915.   \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno{#3}}%
  1916. % Typeset the label for a chapter or appendix for the short contents.
  1917. % The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter.
  1918. % We could simplify the code here by writing out an \appendixentry
  1919. % command in the toc file for appendices, instead of using \chapentry
  1920. % for both, but it doesn't seem worth it.
  1921. \setbox0 = \hbox{\shortcontrm Appendix }
  1922. \newdimen\shortappendixwidth \shortappendixwidth = \wd0
  1923. \def\shortchaplabel#1{%
  1924.   % We typeset #1 in a box of constant width, regardless of the text of
  1925.   % #1, so the chapter titles will come out aligned.
  1926.   \setbox0 = \hbox{#1}%
  1927.   \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi
  1928.   % This space should be plenty, since a single number is .5em, and the
  1929.   % widest letter (M) is 1em, at least in the Computer Modern fonts.
  1930.   % (This space doesn't include the extra space that gets added after
  1931.   % the label; that gets put in in \shortchapentry above.)
  1932.   \advance\dimen0 by 1.1em
  1933.   \hbox to \dimen0{#1\hfil}%
  1934. \def\unnumbchapentry#1#2{\dochapentry{#1}{#2}}
  1935. \def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno{#2}}}
  1936. % Sections.
  1937. \def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}}
  1938. \def\unnumbsecentry#1#2{\dosecentry{#1}{#2}}
  1939. % Subsections.
  1940. \def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}}
  1941. \def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}}
  1942. % And subsubsections.
  1943. \def\subsubsecentry#1#2#3#4#5#6{%
  1944.   \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}}
  1945. \def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}}
  1946. % This parameter controls the indentation of the various levels.
  1947. \newdimen\tocindent \tocindent = 3pc
  1948. % Now for the actual typesetting. In all these, #1 is the text and #2 is the 
  1949. % page number.
  1950. % If the toc has to be broken over pages, we would want to be at chapters 
  1951. % if at all possible; hence the \penalty.
  1952. \def\dochapentry#1#2{%
  1953.    \penalty-300 \vskip\baselineskip
  1954.    \begingroup
  1955.      \chapentryfonts
  1956.      \tocentry{#1}{\dopageno{#2}}%
  1957.    \endgroup
  1958.    \nobreak\vskip .25\baselineskip
  1959. \def\dosecentry#1#2{\begingroup
  1960.   \secentryfonts \leftskip=\tocindent
  1961.   \tocentry{#1}{\dopageno{#2}}%
  1962. \endgroup}
  1963. \def\dosubsecentry#1#2{\begingroup
  1964.   \subsecentryfonts \leftskip=2\tocindent
  1965.   \tocentry{#1}{\dopageno{#2}}%
  1966. \endgroup}
  1967. \def\dosubsubsecentry#1#2{\begingroup
  1968.   \subsubsecentryfonts \leftskip=3\tocindent
  1969.   \tocentry{#1}{\dopageno{#2}}%
  1970. \endgroup}
  1971. % Final typesetting of a toc entry; we use the same \entry macro as for
  1972. % the index entries, but we want to suppress hyphenation here.  (We
  1973. % can't do that in the \entry macro, since index entries might consist
  1974. % of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.)
  1975. \def\tocentry#1#2{\begingroup
  1976.   \hyphenpenalty = 10000
  1977.   \entry{#1}{#2}%
  1978. \endgroup}
  1979. % Space between chapter (or whatever) number and the title.
  1980. \def\labelspace{\hskip1em \relax}
  1981. \def\dopageno#1{{\rm #1}}
  1982. \def\doshortpageno#1{{\rm #1}}
  1983. \def\chapentryfonts{\secfonts \rm}
  1984. \def\secentryfonts{\textfonts}
  1985. \let\subsecentryfonts = \textfonts
  1986. \let\subsubsecentryfonts = \textfonts
  1987. \message{environments,}
  1988. % Since these characters are used in examples, it should be an even number of 
  1989. % \tt widths. Each \tt character is 1en, so two makes it 1em.
  1990. % Furthermore, these definitions must come after we define our fonts.
  1991. \newbox\dblarrowbox    \newbox\longdblarrowbox
  1992. \newbox\pushcharbox    \newbox\bullbox
  1993. \newbox\equivbox       \newbox\errorbox
  1994. \let\ptexequiv = \equiv
  1995. %{\tentt
  1996. %\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil}
  1997. %\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil}
  1998. %\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil}
  1999. %\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil}
  2000. % Adapted from the manmac format (p.420 of TeXbook)
  2001. %\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex
  2002. %                                      depth .1ex\hfil}
  2003. \def\point{$\star$}
  2004. \def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
  2005. \def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}}
  2006. \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
  2007. \def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}}
  2008. % Adapted from the TeXbook's \boxit.
  2009. {\tentt \global\dimen0 = 3em}% Width of the box.
  2010. \dimen2 = .55pt % Thickness of rules
  2011. % The text. (`r' is open on the right, `e' somewhat less so on the left.)
  2012. \setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
  2013. \global\setbox\errorbox=\hbox to \dimen0{\hfil
  2014.    \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
  2015.    \advance\hsize by -2\dimen2 % Rules.
  2016.    \vbox{
  2017.       \hrule height\dimen2
  2018.       \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
  2019.          \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
  2020.          \kern3pt\vrule width\dimen2}% Space to right.
  2021.       \hrule height\dimen2}
  2022.     \hfil}
  2023. % The @error{} command.
  2024. \def\error{\leavevmode\lower.7ex\copy\errorbox}
  2025. % @tex ... @end tex    escapes into raw Tex temporarily.
  2026. % One exception: @ is still an escape character, so that @end tex works.
  2027. % But \@ or @@ will get a plain tex @ character.
  2028. \def\tex{\begingroup
  2029. \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
  2030. \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
  2031. \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie
  2032. \catcode `\%=14
  2033. \catcode 43=12
  2034. \catcode`\"=12
  2035. \catcode`\==12
  2036. \catcode`\|=12
  2037. \catcode`\<=12
  2038. \catcode`\>=12
  2039. \escapechar=`\\
  2040. \let\{=\ptexlbrace
  2041. \let\}=\ptexrbrace
  2042. \let\.=\ptexdot
  2043. \let\*=\ptexstar
  2044. \let\dots=\ptexdots
  2045. \def\@{@}%
  2046. \let\bullet=\ptexbullet
  2047. \let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl
  2048. \let\L=\ptexL
  2049. \let\Etex=\endgroup}
  2050. % Define @lisp ... @endlisp.
  2051. % @lisp does a \begingroup so it can rebind things,
  2052. % including the definition of @endlisp (which normally is erroneous).
  2053. % Amount to narrow the margins by for @lisp.
  2054. \newskip\lispnarrowing \lispnarrowing=0.4in
  2055. % This is the definition that ^M gets inside @lisp
  2056. % phr: changed space to \null, to avoid overfull hbox problems.
  2057. {\obeyspaces%
  2058. \gdef\lisppar{\null\endgraf}}
  2059. % Cause \obeyspaces to make each Space cause a word-separation
  2060. % rather than the default which is that it acts punctuation.
  2061. % This is because space in tt font looks funny.
  2062. {\obeyspaces %
  2063. \gdef\sepspaces{\def {\ }}}
  2064. % This space is always present above and below environments.
  2065. \newskip\envskipamount \envskipamount = 0pt
  2066. % Make spacing and below environment symmetrical.
  2067. \def\aboveenvbreak{{\advance\envskipamount by \parskip
  2068. \endgraf \ifdim\lastskip<\envskipamount
  2069. \removelastskip \penalty-50 \vskip\envskipamount \fi}}
  2070. \let\afterenvbreak = \aboveenvbreak
  2071. % \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins.
  2072. \let\nonarrowing=\relax
  2073. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2074. % \cartouche: draw rectangle w/rounded corners around argument
  2075. \font\circle=lcircle10
  2076. \newdimen\circthick
  2077. \newdimen\cartouter\newdimen\cartinner
  2078. \newskip\normbskip\newskip\normpskip\newskip\normlskip
  2079. \circthick=\fontdimen8\circle
  2080. \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
  2081. \def\ctr{{\hskip 6pt\circle\char'010}}
  2082. \def\cbl{{\circle\char'012\hskip -6pt}}
  2083. \def\cbr{{\hskip 6pt\circle\char'011}}
  2084. \def\carttop{\hbox to \cartouter{\hskip\lskip
  2085.     \ctl\leaders\hrule height\circthick\hfil\ctr
  2086.     \hskip\rskip}}
  2087. \def\cartbot{\hbox to \cartouter{\hskip\lskip
  2088.     \cbl\leaders\hrule height\circthick\hfil\cbr
  2089.     \hskip\rskip}}
  2090. \newskip\lskip\newskip\rskip
  2091. \long\def\cartouche{%
  2092. \begingroup
  2093.     \lskip=\leftskip \rskip=\rightskip
  2094.     \leftskip=0pt\rightskip=0pt %we want these *outside*.
  2095.     \cartinner=\hsize \advance\cartinner by-\lskip 
  2096.                \advance\cartinner by-\rskip
  2097.     \cartouter=\hsize
  2098.     \advance\cartouter by 18pt % allow for 3pt kerns on either
  2099. %                     side, and for 6pt waste from
  2100. %                     each corner char
  2101.     \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
  2102.     % Flag to tell @lisp, etc., not to narrow margin.
  2103.     \let\nonarrowing=\comment
  2104.     \vbox\bgroup
  2105.         \baselineskip=0pt\parskip=0pt\lineskip=0pt
  2106.         \carttop
  2107.         \hbox\bgroup
  2108.             \hskip\lskip
  2109.             \vrule\kern3pt
  2110.             \vbox\bgroup
  2111.                 \hsize=\cartinner
  2112.                 \kern3pt
  2113.                 \begingroup
  2114.                     \baselineskip=\normbskip
  2115.                     \lineskip=\normlskip
  2116.                     \parskip=\normpskip
  2117.                     \vskip -\parskip
  2118. \def\Ecartouche{%
  2119.                 \endgroup
  2120.                 \kern3pt
  2121.             \egroup
  2122.             \kern3pt\vrule
  2123.             \hskip\rskip
  2124.         \egroup
  2125.         \cartbot
  2126.     \egroup
  2127. \endgroup
  2128. \def\lisp{\aboveenvbreak
  2129. \begingroup\inENV % This group ends at the end of the @lisp body
  2130. \hfuzz=12truept % Don't be fussy
  2131. % Make spaces be word-separators rather than space tokens.
  2132. \sepspaces %
  2133. % Single space lines
  2134. \singlespace %
  2135. % The following causes blank lines not to be ignored
  2136. % by adding a space to the end of each line.
  2137. \let\par=\lisppar
  2138. \def\Elisp{\endgroup\afterenvbreak}%
  2139. \parskip=0pt
  2140. % @cartouche defines \nonarrowing to inhibit narrowing
  2141. % at next level down.
  2142. \ifx\nonarrowing\relax
  2143. \advance \leftskip by \lispnarrowing
  2144. \exdentamount=\lispnarrowing
  2145. \let\exdent=\nofillexdent
  2146. \let\nonarrowing=\relax
  2147. \parindent=0pt
  2148. \obeyspaces \obeylines \tt \rawbackslash
  2149. \gobble
  2150. % Define the \E... control sequence only if we are inside the
  2151. % environment, so the error checking in \end will work.
  2152. % We must call \lisp last in the definition, since it reads the
  2153. % return following the @example (or whatever) command.
  2154. \def\example{\begingroup \def\Eexample{\Elisp\endgroup}\lisp}
  2155. \def\smallexample{\begingroup \def\Esmallexample{\Elisp\endgroup}\lisp}
  2156. % Macro for 9 pt. examples, necessary to print with 5" lines.
  2157. % From Pavel@xerox.  This is not really used unless the
  2158. % @smallbook command is given.
  2159. \def\smalllispx{\aboveenvbreak\begingroup\inENV
  2160. %            This group ends at the end of the @lisp body
  2161. \hfuzz=12truept % Don't be fussy
  2162. % Make spaces be word-separators rather than space tokens.
  2163. \sepspaces %
  2164. % Single space lines
  2165. \singlespace %
  2166. % The following causes blank lines not to be ignored
  2167. % by adding a space to the end of each line.
  2168. \let\par=\lisppar
  2169. \def\Esmalllisp{\endgroup\afterenvbreak}%
  2170. %%%% Smaller baseline skip for small examples.
  2171. \baselineskip 10pt
  2172. \parskip=0pt
  2173. % @cartouche defines \nonarrowing to inhibit narrowing
  2174. % at next level down.
  2175. \ifx\nonarrowing\relax
  2176. \advance \leftskip by \lispnarrowing
  2177. \exdentamount=\lispnarrowing
  2178. \let\exdent=\nofillexdent
  2179. \let\nonarrowing=\relax
  2180. \parindent=0pt
  2181. \obeyspaces \obeylines \ninett \indexfonts \rawbackslash
  2182. \def\next##1{}\next}
  2183. % This is @display; same as @lisp except use roman font.
  2184. \def\display{\begingroup\inENV %This group ends at the end of the @display body
  2185. \aboveenvbreak
  2186. % Make spaces be word-separators rather than space tokens.
  2187. \sepspaces %
  2188. % Single space lines
  2189. \singlespace %
  2190. % The following causes blank lines not to be ignored
  2191. % by adding a space to the end of each line.
  2192. \let\par=\lisppar
  2193. \def\Edisplay{\endgroup\afterenvbreak}%
  2194. \parskip=0pt
  2195. % @cartouche defines \nonarrowing to inhibit narrowing
  2196. % at next level down.
  2197. \ifx\nonarrowing\relax
  2198. \advance \leftskip by \lispnarrowing
  2199. \exdentamount=\lispnarrowing
  2200. \let\exdent=\nofillexdent
  2201. \let\nonarrowing=\relax
  2202. \parindent=0pt
  2203. \obeyspaces \obeylines
  2204. \def\next##1{}\next}
  2205. % This is @format; same as @lisp except use roman font and don't narrow margins
  2206. \def\format{\begingroup\inENV %This group ends at the end of the @format body
  2207. \aboveenvbreak
  2208. % Make spaces be word-separators rather than space tokens.
  2209. \sepspaces %
  2210. \singlespace %
  2211. % The following causes blank lines not to be ignored
  2212. % by adding a space to the end of each line.
  2213. \let\par=\lisppar
  2214. \def\Eformat{\endgroup\afterenvbreak}
  2215. \parskip=0pt \parindent=0pt
  2216. \obeyspaces \obeylines
  2217. \def\next##1{}\next}
  2218. % @flushleft and @flushright
  2219. \def\flushleft{%
  2220. \begingroup\inENV %This group ends at the end of the @format body
  2221. \aboveenvbreak
  2222. % Make spaces be word-separators rather than space tokens.
  2223. \sepspaces %
  2224. % The following causes blank lines not to be ignored
  2225. % by adding a space to the end of each line.
  2226. % This also causes @ to work when the directive name
  2227. % is terminated by end of line.
  2228. \let\par=\lisppar
  2229. \def\Eflushleft{\endgroup\afterenvbreak}%
  2230. \parskip=0pt \parindent=0pt
  2231. \obeyspaces \obeylines
  2232. \def\next##1{}\next}
  2233. \def\flushright{%
  2234. \begingroup\inENV %This group ends at the end of the @format body
  2235. \aboveenvbreak
  2236. % Make spaces be word-separators rather than space tokens.
  2237. \sepspaces %
  2238. % The following causes blank lines not to be ignored
  2239. % by adding a space to the end of each line.
  2240. % This also causes @ to work when the directive name
  2241. % is terminated by end of line.
  2242. \let\par=\lisppar
  2243. \def\Eflushright{\endgroup\afterenvbreak}%
  2244. \parskip=0pt \parindent=0pt
  2245. \advance \leftskip by 0pt plus 1fill
  2246. \obeyspaces \obeylines
  2247. \def\next##1{}\next}
  2248. % @quotation - narrow the margins.
  2249. \def\quotation{%
  2250. \begingroup\inENV %This group ends at the end of the @quotation body
  2251. {\parskip=0pt  % because we will skip by \parskip too, later
  2252. \aboveenvbreak}%
  2253. \singlespace
  2254. \parindent=0pt
  2255. \def\Equotation{\par\endgroup\afterenvbreak}%
  2256. % @cartouche defines \nonarrowing to inhibit narrowing
  2257. % at next level down.
  2258. \ifx\nonarrowing\relax
  2259. \advance \leftskip by \lispnarrowing
  2260. \advance \rightskip by \lispnarrowing
  2261. \exdentamount=\lispnarrowing
  2262. \let\nonarrowing=\relax
  2263. \message{defuns,}
  2264. % Define formatter for defuns
  2265. % First, allow user to change definition object font (\df) internally
  2266. \def\setdeffont #1 {\csname DEF#1\endcsname}
  2267. \newskip\defbodyindent \defbodyindent=.4in
  2268. \newskip\defargsindent \defargsindent=50pt
  2269. \newskip\deftypemargin \deftypemargin=12pt
  2270. \newskip\deflastargmargin \deflastargmargin=18pt
  2271. \newcount\parencount
  2272. % define \functionparens, which makes ( and ) and & do special things.
  2273. % \functionparens affects the group it is contained in.
  2274. \def\activeparens{%
  2275. \catcode`\(=\active \catcode`\)=\active \catcode`\&=\active
  2276. \catcode`\[=\active \catcode`\]=\active}
  2277. % Make control sequences which act like normal parenthesis chars.
  2278. \let\lparen = ( \let\rparen = )
  2279. {\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
  2280. % Be sure that we always have a definition for `(', etc.  For example,
  2281. % if the fn name has parens in it, \boldbrax will not be in effect yet,
  2282. % so TeX would otherwise complain about undefined control sequence.
  2283. \global\let(=\lparen \global\let)=\rparen
  2284. \global\let[=\lbrack \global\let]=\rbrack
  2285. \gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
  2286. \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
  2287. % Definitions of (, ) and & used in args for functions.
  2288. % This is the definition of ( outside of all parentheses.
  2289. \gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested %
  2290. \global\advance\parencount by 1 }
  2291. % This is the definition of ( when already inside a level of parens.
  2292. \gdef\opnested{\char`\(\global\advance\parencount by 1 }
  2293. \gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
  2294. % also in that case restore the outer-level definition of (.
  2295. \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
  2296. \global\advance \parencount by -1 }
  2297. % If we encounter &foo, then turn on ()-hacking afterwards
  2298. \gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ }
  2299. \gdef\normalparens{\boldbrax\let&=\ampnr}
  2300. } % End of definition inside \activeparens
  2301. %% These parens (in \boldbrax) actually are a little bolder than the
  2302. %% contained text.  This is especially needed for [ and ]
  2303. \def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&}
  2304. \def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}}
  2305. % First, defname, which formats the header line itself.
  2306. % #1 should be the function name.
  2307. % #2 should be the type of definition, such as "Function".
  2308. \def\defname #1#2{%
  2309. % Get the values of \leftskip and \rightskip as they were
  2310. % outside the @def...
  2311. \dimen2=\leftskip
  2312. \advance\dimen2 by -\defbodyindent
  2313. \dimen3=\rightskip
  2314. \advance\dimen3 by -\defbodyindent
  2315. \noindent        %
  2316. \setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
  2317. \dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
  2318. \dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
  2319. \parshape 2 0in \dimen0 \defargsindent \dimen1     %
  2320. % Now output arg 2 ("Function" or some such)
  2321. % ending at \deftypemargin from the right margin,
  2322. % but stuck inside a box of width 0 so it does not interfere with linebreaking
  2323. {% Adjust \hsize to exclude the ambient margins,
  2324. % so that \rightline will obey them.
  2325. \advance \hsize by -\dimen2 \advance \hsize by -\dimen3
  2326. \rlap{\rightline{{\rm #2}\hskip \deftypemargin}}}%
  2327. % Make all lines underfull and no complaints:
  2328. \tolerance=10000 \hbadness=10000    
  2329. \advance\leftskip by -\defbodyindent
  2330. \exdentamount=\defbodyindent
  2331. {\df #1}\enskip        % Generate function name
  2332. % Actually process the body of a definition
  2333. % #1 should be the terminating control sequence, such as \Edefun.
  2334. % #2 should be the "another name" control sequence, such as \defunx.
  2335. % #3 should be the control sequence that actually processes the header,
  2336. %    such as \defunheader.
  2337. \def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
  2338. \medbreak %
  2339. % Define the end token that this defining construct specifies
  2340. % so that it will exit this group.
  2341. \def#1{\endgraf\endgroup\medbreak}%
  2342. \def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
  2343. \parindent=0in
  2344. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2345. \exdentamount=\defbodyindent
  2346. \begingroup %
  2347. \catcode 61=\active %
  2348. \obeylines\activeparens\spacesplit#3}
  2349. \def\defmethparsebody #1#2#3#4 {\begingroup\inENV %
  2350. \medbreak %
  2351. % Define the end token that this defining construct specifies
  2352. % so that it will exit this group.
  2353. \def#1{\endgraf\endgroup\medbreak}%
  2354. \def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
  2355. \parindent=0in
  2356. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2357. \exdentamount=\defbodyindent
  2358. \begingroup\obeylines\activeparens\spacesplit{#3{#4}}}
  2359. \def\defopparsebody #1#2#3#4#5 {\begingroup\inENV %
  2360. \medbreak %
  2361. % Define the end token that this defining construct specifies
  2362. % so that it will exit this group.
  2363. \def#1{\endgraf\endgroup\medbreak}%
  2364. \def#2##1 ##2 {\def#4{##1}%
  2365. \begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
  2366. \parindent=0in
  2367. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2368. \exdentamount=\defbodyindent
  2369. \begingroup\obeylines\activeparens\spacesplit{#3{#5}}}
  2370. % These parsing functions are similar to the preceding ones
  2371. % except that they do not make parens into active characters.
  2372. % These are used for "variables" since they have no arguments.
  2373. \def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
  2374. \medbreak %
  2375. % Define the end token that this defining construct specifies
  2376. % so that it will exit this group.
  2377. \def#1{\endgraf\endgroup\medbreak}%
  2378. \def#2{\begingroup\obeylines\spacesplit#3}%
  2379. \parindent=0in
  2380. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2381. \exdentamount=\defbodyindent
  2382. \begingroup %
  2383. \catcode 61=\active %
  2384. \obeylines\spacesplit#3}
  2385. \def\defvrparsebody #1#2#3#4 {\begingroup\inENV %
  2386. \medbreak %
  2387. % Define the end token that this defining construct specifies
  2388. % so that it will exit this group.
  2389. \def#1{\endgraf\endgroup\medbreak}%
  2390. \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
  2391. \parindent=0in
  2392. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2393. \exdentamount=\defbodyindent
  2394. \begingroup\obeylines\spacesplit{#3{#4}}}
  2395. % This is the same as all the others except for the last line.  We need
  2396. % to parse the arguments differently for @deftp, since the ``attributes''
  2397. % there are optional.
  2398. \def\deftpparsebody #1#2#3#4 {\begingroup\inENV %
  2399. \medbreak %
  2400. % Define the end token that this defining construct specifies
  2401. % so that it will exit this group.
  2402. \def#1{\endgraf\endgroup\medbreak}%
  2403. \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
  2404. \parindent=0in
  2405. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2406. \exdentamount=\defbodyindent
  2407. \begingroup\obeylines\parsetpheaderline{#3{#4}}}
  2408. {\obeylines %
  2409.   % Parse the type name and any attributes (field names, etc.).
  2410.   % #1 is the beginning of the macro call that will produce the output,
  2411.   %   i.e., \deftpheader{CLASS}; this is passed from \deftpparsebody.
  2412.   % #2 is the type name, e.g., `struct termios'.
  2413.   % #3 is the (possibly empty) attribute list.
  2414.   \gdef\parsetpheaderline#1#2#3^^M{%
  2415.     \endgroup % Started in \deftpparsebody.
  2416.     %
  2417.     % If the attribute list is in fact empty, there will be no space after
  2418.     % #2; so we can't put a space in our TeX parameter list.  But if it
  2419.     % isn't empty, then #3 will begin with an unwanted space.
  2420.     \def\theargs{\ignorespaces #3}%
  2421.     %
  2422.     % Call the macro to produce the output.
  2423.     #1{#2}\theargs %
  2424. \def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV %
  2425. \medbreak %
  2426. % Define the end token that this defining construct specifies
  2427. % so that it will exit this group.
  2428. \def#1{\endgraf\endgroup\medbreak}%
  2429. \def#2##1 ##2 {\def#4{##1}%
  2430. \begingroup\obeylines\spacesplit{#3{##2}}}%
  2431. \parindent=0in
  2432. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2433. \exdentamount=\defbodyindent
  2434. \begingroup\obeylines\spacesplit{#3{#5}}}
  2435. % Split up #2 at the first space token.
  2436. % call #1 with two arguments:
  2437. %  the first is all of #2 before the space token,
  2438. %  the second is all of #2 after that space token.
  2439. % If #2 contains no space token, all of it is passed as the first arg
  2440. % and the second is passed as empty.
  2441. {\obeylines
  2442. \gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
  2443. \long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
  2444. \ifx\relax #3%
  2445. #1{#2}{}\else #1{#2}{#3#4}\fi}}
  2446. % So much for the things common to all kinds of definitions.
  2447. % Define @defun.
  2448. % First, define the processing that is wanted for arguments of \defun
  2449. % Use this to expand the args and terminate the paragraph they make up
  2450. \def\defunargs #1{\functionparens \sl
  2451. % Expand, preventing hyphenation at `-' chars.
  2452. % Note that groups don't affect changes in \hyphenchar.
  2453. \hyphenchar\tensl=0
  2454. \hyphenchar\tensl=45
  2455. \ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi%
  2456. \interlinepenalty=10000
  2457. \advance\rightskip by 0pt plus 1fil
  2458. \endgraf\penalty 10000\vskip -\parskip\penalty 10000%
  2459. \def\deftypefunargs #1{%
  2460. % Expand, preventing hyphenation at `-' chars.
  2461. % Note that groups don't affect changes in \hyphenchar.
  2462. \functionparens
  2463. \code{#1}%
  2464. \interlinepenalty=10000
  2465. \advance\rightskip by 0pt plus 1fil
  2466. \endgraf\penalty 10000\vskip -\parskip\penalty 10000%
  2467. % Do complete processing of one @defun or @defunx line already parsed.
  2468. % @deffn Command forward-char nchars
  2469. \def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
  2470. \def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
  2471. \begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
  2472. \catcode 61=\other % Turn off change made in \defparsebody
  2473. % @defun == @deffn Function
  2474. \def\defun{\defparsebody\Edefun\defunx\defunheader}
  2475. \def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2476. \begingroup\defname {#1}{Function}%
  2477. \defunargs {#2}\endgroup %
  2478. \catcode 61=\other % Turn off change made in \defparsebody
  2479. % @deftypefun int foobar (int @var{foo}, float @var{bar})
  2480. \def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader}
  2481. % #1 is the data type.  #2 is the name and args.
  2482. \def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax}
  2483. % #1 is the data type, #2 the name, #3 the args.
  2484. \def\deftypefunheaderx #1#2 #3\relax{%
  2485. \doind {fn}{\code{#2}}% Make entry in function index
  2486. \begingroup\defname {\code{#1} #2}{Function}%
  2487. \deftypefunargs {#3}\endgroup %
  2488. \catcode 61=\other % Turn off change made in \defparsebody
  2489. % @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar})
  2490. \def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader}
  2491. % #1 is the classification.  #2 is the data type.  #3 is the name and args.
  2492. \def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax}
  2493. % #1 is the classification, #2 the data type, #3 the name, #4 the args.
  2494. \def\deftypefnheaderx #1#2#3 #4\relax{%
  2495. \doind {fn}{\code{#3}}% Make entry in function index
  2496. \begingroup\defname {\code{#2} #3}{#1}%
  2497. \deftypefunargs {#4}\endgroup %
  2498. \catcode 61=\other % Turn off change made in \defparsebody
  2499. % @defmac == @deffn Macro
  2500. \def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
  2501. \def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2502. \begingroup\defname {#1}{Macro}%
  2503. \defunargs {#2}\endgroup %
  2504. \catcode 61=\other % Turn off change made in \defparsebody
  2505. % @defspec == @deffn Special Form
  2506. \def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
  2507. \def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2508. \begingroup\defname {#1}{Special Form}%
  2509. \defunargs {#2}\endgroup %
  2510. \catcode 61=\other % Turn off change made in \defparsebody
  2511. % This definition is run if you use @defunx
  2512. % anywhere other than immediately after a @defun or @defunx.
  2513. \def\deffnx #1 {\errmessage{@deffnx in invalid context}}
  2514. \def\defunx #1 {\errmessage{@defunx in invalid context}}
  2515. \def\defmacx #1 {\errmessage{@defmacx in invalid context}}
  2516. \def\defspecx #1 {\errmessage{@defspecx in invalid context}}
  2517. \def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}}
  2518. \def\deftypeunx #1 {\errmessage{@deftypeunx in invalid context}}
  2519. % @defmethod, and so on
  2520. % @defop {Funny Method} foo-class frobnicate argument
  2521. \def\defop #1 {\def\defoptype{#1}%
  2522. \defopparsebody\Edefop\defopx\defopheader\defoptype}
  2523. \def\defopheader #1#2#3{%
  2524. \dosubind {fn}{\code{#2}}{on #1}% Make entry in function index
  2525. \begingroup\defname {#2}{\defoptype{} on #1}%
  2526. \defunargs {#3}\endgroup %
  2527. % @defmethod == @defop Method
  2528. \def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
  2529. \def\defmethodheader #1#2#3{%
  2530. \dosubind {fn}{\code{#2}}{on #1}% entry in function index
  2531. \begingroup\defname {#2}{Method on #1}%
  2532. \defunargs {#3}\endgroup %
  2533. % @defcv {Class Option} foo-class foo-flag
  2534. \def\defcv #1 {\def\defcvtype{#1}%
  2535. \defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
  2536. \def\defcvarheader #1#2#3{%
  2537. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  2538. \begingroup\defname {#2}{\defcvtype{} of #1}%
  2539. \defvarargs {#3}\endgroup %
  2540. % @defivar == @defcv {Instance Variable}
  2541. \def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader}
  2542. \def\defivarheader #1#2#3{%
  2543. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  2544. \begingroup\defname {#2}{Instance Variable of #1}%
  2545. \defvarargs {#3}\endgroup %
  2546. % These definitions are run if you use @defmethodx, etc.,
  2547. % anywhere other than immediately after a @defmethod, etc.
  2548. \def\defopx #1 {\errmessage{@defopx in invalid context}}
  2549. \def\defmethodx #1 {\errmessage{@defmethodx in invalid context}}
  2550. \def\defcvx #1 {\errmessage{@defcvx in invalid context}}
  2551. \def\defivarx #1 {\errmessage{@defivarx in invalid context}}
  2552. % Now @defvar
  2553. % First, define the processing that is wanted for arguments of @defvar.
  2554. % This is actually simple: just print them in roman.
  2555. % This must expand the args and terminate the paragraph they make up
  2556. \def\defvarargs #1{\normalparens #1%
  2557. \interlinepenalty=10000
  2558. \endgraf\penalty 10000\vskip -\parskip\penalty 10000}
  2559. % @defvr Counter foo-count
  2560. \def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader}
  2561. \def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
  2562. \begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
  2563. % @defvar == @defvr Variable
  2564. \def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader}
  2565. \def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  2566. \begingroup\defname {#1}{Variable}%
  2567. \defvarargs {#2}\endgroup %
  2568. % @defopt == @defvr {User Option}
  2569. \def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader}
  2570. \def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  2571. \begingroup\defname {#1}{User Option}%
  2572. \defvarargs {#2}\endgroup %
  2573. % @deftypevar int foobar
  2574. \def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader}
  2575. % #1 is the data type.  #2 is the name.
  2576. \def\deftypevarheader #1#2{%
  2577. \doind {vr}{\code{#2}}% Make entry in variables index
  2578. \begingroup\defname {\code{#1} #2}{Variable}%
  2579. \interlinepenalty=10000
  2580. \endgraf\penalty 10000\vskip -\parskip\penalty 10000
  2581. \endgroup}
  2582. % @deftypevr {Global Flag} int enable
  2583. \def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader}
  2584. \def\deftypevrheader #1#2#3{\doind {vr}{\code{#3}}%
  2585. \begingroup\defname {\code{#2} #3}{#1}
  2586. \interlinepenalty=10000
  2587. \endgraf\penalty 10000\vskip -\parskip\penalty 10000
  2588. \endgroup}
  2589. % This definition is run if you use @defvarx
  2590. % anywhere other than immediately after a @defvar or @defvarx.
  2591. \def\defvrx #1 {\errmessage{@defvrx in invalid context}}
  2592. \def\defvarx #1 {\errmessage{@defvarx in invalid context}}
  2593. \def\defoptx #1 {\errmessage{@defoptx in invalid context}}
  2594. \def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}}
  2595. \def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}}
  2596. % Now define @deftp
  2597. % Args are printed in bold, a slight difference from @defvar.
  2598. \def\deftpargs #1{\bf \defvarargs{#1}}
  2599. % @deftp Class window height width ...
  2600. \def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader}
  2601. \def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
  2602. \begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
  2603. % This definition is run if you use @deftpx, etc
  2604. % anywhere other than immediately after a @deftp, etc.
  2605. \def\deftpx #1 {\errmessage{@deftpx in invalid context}}
  2606. \message{cross reference,}
  2607. % Define cross-reference macros
  2608. \newwrite \auxfile
  2609. \newif\ifhavexrefs  % True if xref values are known.
  2610. \newif\ifwarnedxrefs  % True if we warned once that they aren't known.
  2611. % \setref{foo} defines a cross-reference point named foo.
  2612. \def\setref#1{%
  2613. %\dosetq{#1-title}{Ytitle}%
  2614. \dosetq{#1-pg}{Ypagenumber}%
  2615. \dosetq{#1-snt}{Ysectionnumberandtype}}
  2616. \def\unnumbsetref#1{%
  2617. %\dosetq{#1-title}{Ytitle}%
  2618. \dosetq{#1-pg}{Ypagenumber}%
  2619. \dosetq{#1-snt}{Ynothing}}
  2620. \def\appendixsetref#1{%
  2621. %\dosetq{#1-title}{Ytitle}%
  2622. \dosetq{#1-pg}{Ypagenumber}%
  2623. \dosetq{#1-snt}{Yappendixletterandtype}}
  2624. % \xref, \pxref, and \ref generate cross-references to specified points.
  2625. % For \xrefX, #1 is the node name, #2 the name of the Info
  2626. % cross-reference, #3 the printed node name, #4 the name of the Info
  2627. % file, #5 the name of the printed manual.  All but the node name can be
  2628. % omitted.
  2629. \def\pxref#1{see \xrefX[#1,,,,,,,]}
  2630. \def\xref#1{See \xrefX[#1,,,,,,,]}
  2631. \def\ref#1{\xrefX[#1,,,,,,,]}
  2632. \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup%
  2633. \def\printedmanual{\ignorespaces #5}%
  2634. \def\printednodename{\ignorespaces #3}%
  2635. \setbox1=\hbox{\printedmanual}%
  2636. \setbox0=\hbox{\printednodename}%
  2637. \ifdim \wd0=0pt%
  2638. \def\printednodename{\ignorespaces #1}%
  2639. %%% Uncommment the following line to make the actual chapter or section title
  2640. %%% appear inside the square brackets.
  2641. %\def\printednodename{#1-title}%
  2642. % If we use \unhbox0 and \unhbox1 to print the node names, TeX does
  2643. % not insert empty discretionaries after hyphens, which means that it
  2644. % will not find a line break at a hyphen in a node names.  Since some
  2645. % manuals are best written with fairly long node names, containing
  2646. % hyphens, this is a loss.  Therefore, we simply give the text of
  2647. % the node name again, so it is as if TeX is seeing it for the first
  2648. % time.
  2649. \ifdim \wd1>0pt
  2650. section ``\printednodename'' in \cite{\printedmanual}%
  2651. \else%
  2652. \turnoffactive%
  2653. \refx{#1-snt}{} [\printednodename], page\tie\refx{#1-pg}{}%
  2654. \endgroup}
  2655. % \dosetq is the interface for calls from other macros
  2656. % Use \turnoffactive so that punctuation chars such as underscore
  2657. % work in node names.
  2658. \def\dosetq #1#2{{\let\folio=0 \turnoffactive%
  2659. \edef\next{\write\auxfile{\internalsetq {#1}{#2}}}%
  2660. \next}}
  2661. % \internalsetq {foo}{page} expands into
  2662. % CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
  2663. % When the aux file is read, ' is the escape character
  2664. \def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
  2665. % Things to be expanded by \internalsetq
  2666. \def\Ypagenumber{\folio}
  2667. \def\Ytitle{\thischapter}
  2668. \def\Ynothing{}
  2669. \def\Ysectionnumberandtype{%
  2670. \ifnum\secno=0 Chapter\xreftie\the\chapno %
  2671. \else \ifnum \subsecno=0 Section\xreftie\the\chapno.\the\secno %
  2672. \else \ifnum \subsubsecno=0 %
  2673. Section\xreftie\the\chapno.\the\secno.\the\subsecno %
  2674. \else %
  2675. Section\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
  2676. \fi \fi \fi }
  2677. \def\Yappendixletterandtype{%
  2678. \ifnum\secno=0 Appendix\xreftie'char\the\appendixno{}%
  2679. \else \ifnum \subsecno=0 Section\xreftie'char\the\appendixno.\the\secno %
  2680. \else \ifnum \subsubsecno=0 %
  2681. Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
  2682. \else %
  2683. Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
  2684. \fi \fi \fi }
  2685. \gdef\xreftie{'tie}
  2686. % Use TeX 3.0's \inputlineno to get the line number, for better error
  2687. % messages, but if we're using an old version of TeX, don't do anything.
  2688. \ifx\inputlineno\thisisundefined
  2689.   \let\linenumber = \empty % Non-3.0.
  2690. \else
  2691.   \def\linenumber{\the\inputlineno:\space}
  2692. % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
  2693. % If its value is nonempty, SUFFIX is output afterward.
  2694. \def\refx#1#2{%
  2695.   \expandafter\ifx\csname X#1\endcsname\relax
  2696.     % If not defined, say something at least.
  2697.     $\langle$un\-de\-fined$\rangle$%
  2698.     \ifhavexrefs
  2699.       \message{\linenumber Undefined cross reference `#1'.}%
  2700.     \else
  2701.       \ifwarnedxrefs\else
  2702.         \global\warnedxrefstrue
  2703.         \message{Cross reference values unknown; you must run TeX again.}%
  2704.       \fi
  2705.     \fi
  2706.   \else
  2707.     % It's defined, so just use it.
  2708.     \csname X#1\endcsname
  2709.   \fi
  2710.   #2% Output the suffix in any case.
  2711. % Read the last existing aux file, if any.  No error if none exists.
  2712. % This is the macro invoked by entries in the aux file.
  2713. \def\xrdef #1#2{
  2714. {\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}}
  2715. \def\readauxfile{%
  2716. \begingroup
  2717. \catcode `\^^@=\other
  2718. \catcode `\
  2719. =\other
  2720. \catcode `\
  2721. =\other
  2722. \catcode `\^^C=\other
  2723. \catcode `\^^D=\other
  2724. \catcode `\^^E=\other
  2725. \catcode `\^^F=\other
  2726. \catcode `\^^G=\other
  2727. \catcode `\^^H=\other
  2728. \catcode `\
  2729. =\other
  2730. \catcode `\^^L=\other
  2731. \catcode `\
  2732. =\other
  2733. \catcode `\
  2734. =\other
  2735. \catcode `\
  2736. =\other
  2737. \catcode `\
  2738. =\other
  2739. \catcode `\
  2740. =\other
  2741. \catcode `\
  2742. =\other
  2743. \catcode `\
  2744. =\other
  2745. \catcode `\
  2746. =\other
  2747. \catcode `\
  2748. =\other
  2749. \catcode `\
  2750. =\other
  2751. \catcode `\
  2752. =\other
  2753. \catcode `\
  2754. =\other
  2755. \catcode 26=\other
  2756. \catcode `\^^[=\other
  2757. \catcode `\^^\=\other
  2758. \catcode `\^^]=\other
  2759. \catcode `\^^^=\other
  2760. \catcode `\^^_=\other
  2761. \catcode `\@=\other
  2762. \catcode `\^=\other
  2763. \catcode `\~=\other
  2764. \catcode `\[=\other
  2765. \catcode `\]=\other
  2766. \catcode`\"=\other
  2767. \catcode`\_=\other
  2768. \catcode`\|=\other
  2769. \catcode`\<=\other
  2770. \catcode`\>=\other
  2771. \catcode `\$=\other
  2772. \catcode `\#=\other
  2773. \catcode `\&=\other
  2774. % `\+ does not work, so use 43.
  2775. \catcode 43=\other
  2776. % the aux file uses ' as the escape.
  2777. % Turn off \ as an escape so we do not lose on
  2778. % entries which were dumped with control sequences in their names.
  2779. % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^
  2780. % Reference to such entries still does not work the way one would wish,
  2781. % but at least they do not bomb out when the aux file is read in.
  2782. \catcode `\{=1 \catcode `\}=2
  2783. \catcode `\%=\other
  2784. \catcode `\'=0
  2785. \catcode `\\=\other
  2786. \openin 1 \jobname.aux
  2787. \ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue
  2788. % Open the new aux file.  Tex will close it automatically at exit.
  2789. \openout \auxfile=\jobname.aux
  2790. \endgroup}
  2791. % Footnotes.
  2792. \newcount \footnoteno
  2793. % The trailing space in the following definition for supereject is
  2794. % vital for proper filling; pages come out unaligned when you do a
  2795. % pagealignmacro call if that space before the closing brace is
  2796. % removed.
  2797. \def\supereject{\par\penalty -20000\footnoteno =0 }
  2798. % @footnotestyle is meaningful for info output only..
  2799. \let\footnotestyle=\comment
  2800. \let\ptexfootnote=\footnote
  2801. {\catcode `\@=11
  2802. \long\gdef\footnote #1{\global\advance \footnoteno by \@ne
  2803. \unskip
  2804. \edef\thisfootno{$^{\the\footnoteno}$}%
  2805. \let\@sf\empty
  2806. \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
  2807. \thisfootno\@sf \footnotezzz{#1}}
  2808. % \parsearg\footnotezzz}
  2809. \long\gdef\footnotezzz #1{\insert\footins{
  2810. \interlinepenalty\interfootnotelinepenalty
  2811. \splittopskip\ht\strutbox % top baseline for broken footnotes
  2812. \splitmaxdepth\dp\strutbox \floatingpenalty\@MM
  2813. \leftskip\z@skip \rightskip\z@skip \spaceskip\z@skip \xspaceskip\z@skip
  2814. \footstrut\parindent=\defaultparindent\hang\textindent{\thisfootno}#1\strut}}
  2815. }%end \catcode `\@=11
  2816. % Set the baselineskip to #1, and the lineskip and strut size
  2817. % correspondingly.  There is no deep meaning behind these magic numbers
  2818. % used as factors; they just match (closely enough) what Knuth defined.
  2819. \def\lineskipfactor{.1}
  2820. \def\strutheightpercent{.71}
  2821. \def\strutdepthpercent{.29}
  2822. \def\setleading#1{%
  2823.   \baselineskip = #1\relax
  2824.   \normalbaselineskip = \baselineskip
  2825.   \lineskip = \lineskipfactor\baselineskip
  2826.   \setbox\strutbox =\hbox{%
  2827.     \vrule width0pt height\strutheightpercent\baselineskip
  2828.                     depth \strutdepthpercent \baselineskip
  2829. % @| inserts a changebar to the left of the current line.  It should
  2830. % surround any changed text.  This approach does *not* work if the
  2831. % change spans more than two lines of output.  To handle that, we would
  2832. % have adopt a much more difficult approach (putting marks into the main
  2833. % vertical list for the beginning and end of each change).
  2834. \def\|{%
  2835.   % \vadjust can only be used in horizontal mode.
  2836.   \leavevmode
  2837.   % Append this vertical mode material after the current line in the output.
  2838.   \vadjust{%
  2839.     % We want to insert a rule with the height and depth of the current
  2840.     % leading; that is exactly what \strutbox is supposed to record.
  2841.     \vskip-\baselineskip
  2842.     %
  2843.     % \vadjust-items are inserted at the left edge of the type.  So
  2844.     % the \llap here moves out into the left-hand margin.
  2845.     \llap{%
  2846.       %
  2847.       % For a thicker or thinner bar, change the `1pt'.
  2848.       \vrule height\baselineskip width1pt
  2849.       %
  2850.       % This is the space between the bar and the text.
  2851.       \hskip 12pt
  2852.     }%
  2853. % For a final copy, take out the rectangles
  2854. % that mark overfull boxes (in case you have decided
  2855. % that the text looks ok even though it passes the margin).
  2856. \def\finalout{\overfullrule=0pt}
  2857. % End of control word definitions.
  2858. \message{and turning on texinfo input format.}
  2859. \def\openindices{%
  2860.    \newindex{cp}%
  2861.    \newcodeindex{fn}%
  2862.    \newcodeindex{vr}%
  2863.    \newcodeindex{tp}%
  2864.    \newcodeindex{ky}%
  2865.    \newcodeindex{pg}%
  2866. % Set some numeric style parameters, for 8.5 x 11 format.
  2867. %\hsize = 6.5in
  2868. \newdimen\defaultparindent \defaultparindent = 15pt
  2869. \parindent = \defaultparindent
  2870. \parskip 18pt plus 1pt
  2871. \setleading{15pt}
  2872. \advance\topskip by 1.2cm
  2873. % Prevent underfull vbox error messages.
  2874. \vbadness=10000
  2875. % Following George Bush, just get rid of widows and orphans.
  2876. \widowpenalty=10000
  2877. \clubpenalty=10000
  2878. % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
  2879. % using an old version of TeX, don't do anything.  We want the amount of
  2880. % stretch added to depend on the line length, hence the dependence on
  2881. % \hsize.  This makes it come to about 9pt for the 8.5x11 format.
  2882. \ifx\emergencystretch\thisisundefined \else
  2883.   \emergencystretch = \hsize
  2884.   \divide\emergencystretch by 45
  2885. % Use @smallbook to reset parameters for 7x9.5 format  (or else 7x9.25)
  2886. \def\smallbook{
  2887. % These values for secheadingskip and subsecheadingskip are
  2888. % experiments.  RJC 7 Aug 1992
  2889. \global\secheadingskip = 17pt plus 6pt minus 3pt
  2890. \global\subsecheadingskip = 14pt plus 6pt minus 3pt
  2891. \global\lispnarrowing = 0.3in
  2892. \setleading{12pt}
  2893. \advance\topskip by -1cm
  2894. \global\parskip 3pt plus 1pt
  2895. \global\hsize = 5in
  2896. \global\vsize=7.5in
  2897. \global\tolerance=700
  2898. \global\hfuzz=1pt
  2899. \global\contentsrightmargin=0pt
  2900. \global\pagewidth=\hsize
  2901. \global\pageheight=\vsize
  2902. \global\let\smalllisp=\smalllispx
  2903. \global\let\smallexample=\smalllispx
  2904. \global\def\Esmallexample{\Esmalllisp}
  2905. % Use @afourpaper to print on European A4 paper.
  2906. \def\afourpaper{
  2907. \global\tolerance=700
  2908. \global\hfuzz=1pt
  2909. \setleading{12pt}
  2910. \global\parskip 15pt plus 1pt
  2911. \global\vsize= 53\baselineskip
  2912. \advance\vsize by \topskip
  2913. %\global\hsize=   5.85in     % A4 wide 10pt
  2914. \global\hsize=  6.5in
  2915. \global\outerhsize=\hsize
  2916. \global\advance\outerhsize by 0.5in
  2917. \global\outervsize=\vsize
  2918. \global\advance\outervsize by 0.6in
  2919. \global\pagewidth=\hsize
  2920. \global\pageheight=\vsize
  2921. % Define macros to output various characters with catcode for normal text.
  2922. \catcode`\"=\other
  2923. \catcode`\~=\other
  2924. \catcode`\^=\other
  2925. \catcode`\_=\other
  2926. \catcode`\|=\other
  2927. \catcode`\<=\other
  2928. \catcode`\>=\other
  2929. \catcode`\+=\other
  2930. \def\normaldoublequote{"}
  2931. \def\normaltilde{~}
  2932. \def\normalcaret{^}
  2933. \def\normalunderscore{_}
  2934. \def\normalverticalbar{|}
  2935. \def\normalless{<}
  2936. \def\normalgreater{>}
  2937. \def\normalplus{+}
  2938. % This macro is used to make a character print one way in ttfont
  2939. % where it can probably just be output, and another way in other fonts,
  2940. % where something hairier probably needs to be done.
  2941. % #1 is what to print if we are indeed using \tt; #2 is what to print
  2942. % otherwise.  Since all the Computer Modern typewriter fonts have zero
  2943. % interword stretch (and shrink), and it is reasonable to expect all
  2944. % typewriter fonts to have this, we can check that font parameter.
  2945. \def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi}
  2946. % Turn off all special characters except @
  2947. % (and those which the user can use as if they were ordinary).
  2948. % Most of these we simply print from the \tt font, but for some, we can
  2949. % use math or other variants that look better in normal text.
  2950. \catcode`\"=\active
  2951. \def\activedoublequote{{\tt \char '042}}
  2952. \let"=\activedoublequote
  2953. \catcode`\~=\active
  2954. \def~{{\tt \char '176}}
  2955. \chardef\hat=`\^
  2956. \catcode`\^=\active
  2957. \def^{{\tt \hat}}
  2958. \catcode`\_=\active
  2959. \def_{\ifusingtt\normalunderscore\_}
  2960. % Subroutine for the previous macro.
  2961. \def\_{\lvvmode \kern.06em \vbox{\hrule width.3em height.1ex}}
  2962. % \lvvmode is equivalent in function to \leavevmode.
  2963. % Using \leavevmode runs into trouble when written out to
  2964. % an index file due to the expansion of \leavevmode into ``\unhbox
  2965. % \voidb@x'' ---which looks to TeX like ``\unhbox \voidb\x'' due to our
  2966. % magic tricks with @.
  2967. \def\lvvmode{\vbox to 0pt{}}
  2968. \catcode`\|=\active
  2969. \def|{{\tt \char '174}}
  2970. \chardef \less=`\<
  2971. \catcode`\<=\active
  2972. \def<{{\tt \less}}
  2973. \chardef \gtr=`\>
  2974. \catcode`\>=\active
  2975. \def>{{\tt \gtr}}
  2976. \catcode`\+=\active
  2977. \def+{{\tt \char 43}}
  2978. %\catcode 27=\active
  2979. %\def^^[{$\diamondsuit$}
  2980. % Used sometimes to turn off (effectively) the active characters
  2981. % even after parsing them.
  2982. \def\turnoffactive{\let"=\normaldoublequote
  2983. \let~=\normaltilde
  2984. \let^=\normalcaret
  2985. \let_=\normalunderscore
  2986. \let|=\normalverticalbar
  2987. \let<=\normalless
  2988. \let>=\normalgreater
  2989. \let+=\normalplus}
  2990. % Set up an active definition for =, but don't enable it most of the time.
  2991. {\catcode`\==\active
  2992. \global\def={{\tt \char 61}}}
  2993. \catcode`\@=0
  2994. % \rawbackslashxx output one backslash character in current font
  2995. \global\chardef\rawbackslashxx=`\\
  2996. %{\catcode`\\=\other
  2997. %@gdef@rawbackslashxx{\}}
  2998. % \rawbackslash redefines \ as input to do \rawbackslashxx.
  2999. {\catcode`\\=\active
  3000. @gdef@rawbackslash{@let\=@rawbackslashxx }}
  3001. % \normalbackslash outputs one backslash in fixed width font.
  3002. \def\normalbackslash{{\tt\rawbackslashxx}}
  3003. % Say @foo, not \foo, in error messages.
  3004. \escapechar=`\@
  3005. % \catcode 17=0   % Define control-q
  3006. \catcode`\\=\active
  3007. % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
  3008. % That is what \eatinput is for; after that, the `\' should revert to printing 
  3009. % a backslash.
  3010. @gdef@eatinput input texinfo{@fixbackslash}
  3011. @global@let\ = @eatinput
  3012. % On the other hand, perhaps the file did not have a `\input texinfo'. Then
  3013. % the first `\{ in the file would cause an error. This macro tries to fix 
  3014. % that, assuming it is called before the first `\' could plausibly occur.
  3015. @gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi}
  3016. %% These look ok in all fonts, so just make them not special.  The @rm below
  3017. %% makes sure that the current font starts out as the newly loaded cmr10
  3018. @catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other
  3019. @textfonts
  3020. @c Local variables:
  3021. @c page-delimiter: "^\\\\message"
  3022. @c End:
  3023.